Skip to content

Commit a130c1b

Browse files
committed
added test, tolerating non-DDL, non-DML keywords like BEGIN
1 parent 431a432 commit a130c1b

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
package_dir={"": "src"},
1717
packages=["cs50"],
1818
url="https://github.com/cs50/python-cs50",
19-
version="5.0.2"
19+
version="5.0.3"
2020
)

src/cs50/sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def execute(self, sql, *args, **kwargs):
126126
command = token.value.upper()
127127
break
128128
else:
129-
raise RuntimeError("unrecognized command")
129+
command = None
130130

131131
# Flatten statement
132132
tokens = list(statements[0].flatten())

tests/sql.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ def test_rollback(self):
128128
self.db.execute("ROLLBACK")
129129
self.assertEqual(self.db.execute("SELECT val FROM cs50"), [])
130130

131+
def test_cte(self):
132+
self.assertEqual(self.db.execute("WITH foo AS ( SELECT 1 ) SELECT * FROM foo"), [{"1": 1}])
133+
131134
def tearDown(self):
132135
self.db.execute("DROP TABLE cs50")
133136
self.db.execute("DROP TABLE IF EXISTS foo")

0 commit comments

Comments
 (0)