-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Granted permission for root to insert, delete, update on all tables #123
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
class SQLTests(unittest.TestCase): | ||
|
||
def test_multiple_statements(self): | ||
def test_multiple_statements(self): | ||
self.assertRaises(RuntimeError, self.db.execute, "INSERT INTO cs50(val) VALUES('baz'); INSERT INTO cs50(val) VALUES('qux')") | ||
|
||
def test_delete_returns_affected_rows(self): | ||
|
@@ -19,7 +19,7 @@ def test_delete_returns_affected_rows(self): | |
{"id": 3, "val": "baz"} | ||
] | ||
for row in rows: | ||
self.db.execute("INSERT INTO cs50(val) VALUES(:val);", val=row["val"]) | ||
self.db.execute("INSERT INTO cs50(val) VALUES(:val);", val=row["val"]) | ||
self.assertEqual(self.db.execute("DELETE FROM cs50 WHERE id = :id", id=rows[0]["id"]), 1) | ||
self.assertEqual(self.db.execute("DELETE FROM cs50 WHERE id = :a or id = :b", a=rows[1]["id"], b=rows[2]["id"]), 2) | ||
self.assertEqual(self.db.execute("DELETE FROM cs50 WHERE id = -50"), 0) | ||
|
@@ -158,6 +158,11 @@ def setUpClass(self): | |
def setUp(self): | ||
self.db.execute("CREATE TABLE cs50 (id SERIAL PRIMARY KEY, val VARCHAR(16), bin BYTEA)") | ||
|
||
//Granted permision to root to select, insert, update and delete anything on all tables | ||
def setUp(self): | ||
self.db.execute("GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES TO root;") | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure this is solving an open issue? |
||
|
||
def test_cte(self): | ||
self.assertEqual(self.db.execute("WITH foo AS ( SELECT 1 AS bar ) SELECT bar FROM foo"), [{"bar": 1}]) | ||
|
||
|
@@ -172,7 +177,7 @@ def setUp(self): | |
|
||
def test_lastrowid(self): | ||
self.db.execute("CREATE TABLE foo(id INTEGER PRIMARY KEY AUTOINCREMENT, firstname TEXT, lastname TEXT)") | ||
self.assertEqual(self.db.execute("INSERT INTO foo (firstname, lastname) VALUES('firstname', 'lastname')"), 1) | ||
self.assertEqual(sv elf.db.execute("INSERT INTO foo (firstname, lastname) VALUES('firstname', 'lastname')"), 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Afraid this isn't syntactically valid! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It supposed to commit changes only at line 163. I will check where it went wrong, why one line is deleted and is changed by the same line. |
||
self.assertRaises(RuntimeError, self.db.execute, "INSERT INTO foo (id, firstname, lastname) VALUES(1, 'firstname', 'lastname')") | ||
self.assertEqual(self.db.execute("INSERT OR IGNORE INTO foo (id, firstname, lastname) VALUES(1, 'firstname', 'lastname')"), None) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afraid this is incorrectly indented now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, I just inccidentaly copied one row :-D