Skip to content

Commit 82556df

Browse files
author
Jesse Whitehouse
committed
Incorporate e2e test suggested by #56
Signed-off-by: Jesse Whitehouse <[email protected]>
1 parent 6750633 commit 82556df

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/e2e/driver_tests.py

+14
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,20 @@ def test_get_columns(self):
288288
for table in table_names:
289289
cursor.execute('DROP TABLE IF EXISTS {}'.format(table))
290290

291+
def test_escape_single_quotes(self):
292+
with self.cursor({}) as cursor:
293+
table_name = 'table_{uuid}'.format(uuid=str(uuid4()).replace('-', '_'))
294+
# Test escape syntax directly
295+
cursor.execute("CREATE TABLE IF NOT EXISTS {} AS (SELECT 'you\\'re' AS col_1)".format(table_name))
296+
cursor.execute("SELECT * FROM {} WHERE col_1 LIKE 'you\\'re'".format(table_name))
297+
rows = cursor.fetchall()
298+
assert rows[0]["col_1"] == "you're"
299+
300+
# Test escape syntax in parameter
301+
cursor.execute("SELECT * FROM {} WHERE {}.col_1 LIKE %(var)s".format(table_name, table_name), parameters={"var": "you're"})
302+
rows = cursor.fetchall()
303+
assert rows[0]["col_1"] == "you're"
304+
291305
def test_get_schemas(self):
292306
with self.cursor({}) as cursor:
293307
database_name = 'db_{uuid}'.format(uuid=str(uuid4()).replace('-', '_'))

0 commit comments

Comments
 (0)