Skip to content

Commit bd89efc

Browse files
author
Kareem Zidane
authored
Merge pull request #150 from cs50/develop
v6.0.4
2 parents 85b0ae0 + 599d968 commit bd89efc

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

setup.py

+1-1
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="6.0.3"
19+
version="6.0.4"
2020
)

src/cs50/sql.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def execute(self, sql, *args, **kwargs):
114114
import warnings
115115

116116
# Parse statement, stripping comments and then leading/trailing whitespace
117-
statements = sqlparse.parse(sqlparse.format(sql, keyword_case="upper", strip_comments=True).strip())
117+
statements = sqlparse.parse(sqlparse.format(sql, strip_comments=True).strip())
118118

119119
# Allow only one statement at a time, since SQLite doesn't support multiple
120120
# https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.execute
@@ -130,8 +130,9 @@ def execute(self, sql, *args, **kwargs):
130130
# Infer command from (unflattened) statement
131131
for token in statements[0]:
132132
if token.ttype in [sqlparse.tokens.Keyword, sqlparse.tokens.Keyword.DDL, sqlparse.tokens.Keyword.DML]:
133-
if token.value in ["BEGIN", "DELETE", "INSERT", "SELECT", "START", "UPDATE"]:
134-
command = token.value
133+
token_value = token.value.upper()
134+
if token_value in ["BEGIN", "DELETE", "INSERT", "SELECT", "START", "UPDATE"]:
135+
command = token_value
135136
break
136137
else:
137138
command = None

tests/sql.py

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ def test_rollback(self):
129129
self.db.execute("ROLLBACK")
130130
self.assertEqual(self.db.execute("SELECT val FROM cs50"), [])
131131

132+
def test_identifier_case(self):
133+
self.assertIn("count", self.db.execute("SELECT 1 AS count")[0])
134+
132135
def tearDown(self):
133136
self.db.execute("DROP TABLE cs50")
134137
self.db.execute("DROP TABLE IF EXISTS foo")

0 commit comments

Comments
 (0)