summaryrefslogtreecommitdiffstats
path: root/tests/test_sqlcompletion.py
diff options
context:
space:
mode:
authorDarik Gamble <darik.gamble@gmail.com>2015-08-05 15:46:13 -0400
committerDarik Gamble <darik.gamble@gmail.com>2015-08-05 15:46:13 -0400
commit3ef99aa043fc0bc340a6f4cfbea569c6e438a833 (patch)
treec84be6415ff410d390aee8d858874e8470bb426d /tests/test_sqlcompletion.py
parent21125e8820b2de7fdfb11f62b3a2c5bdf12adb92 (diff)
Test suggest_type with escaped table aliases
Diffstat (limited to 'tests/test_sqlcompletion.py')
-rw-r--r--tests/test_sqlcompletion.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/tests/test_sqlcompletion.py b/tests/test_sqlcompletion.py
index 2fe4cbea..d4e52fff 100644
--- a/tests/test_sqlcompletion.py
+++ b/tests/test_sqlcompletion.py
@@ -157,15 +157,37 @@ def test_dot_suggests_cols_of_a_table_or_schema_qualified_table():
{'type': 'view', 'schema': 'tabl'},
{'type': 'function', 'schema': 'tabl'}])
-def test_dot_suggests_cols_of_an_alias():
- suggestions = suggest_type('SELECT t1. FROM tabl1 t1, tabl2 t2',
- 'SELECT t1.')
+
+@pytest.mark.parametrize('sql', [
+ 'SELECT t1. FROM tabl1 t1',
+ 'SELECT t1. FROM tabl1 t1, tabl2 t2',
+ 'SELECT t1. FROM "tabl1" t1',
+ 'SELECT t1. FROM "tabl1" t1, "tabl2" t2',
+ ])
+def test_dot_suggests_cols_of_an_alias(sql):
+ suggestions = suggest_type(sql, 'SELECT t1.')
assert sorted_dicts(suggestions) == sorted_dicts([
{'type': 'table', 'schema': 't1'},
{'type': 'view', 'schema': 't1'},
{'type': 'column', 'tables': [(None, 'tabl1', 't1')]},
{'type': 'function', 'schema': 't1'}])
+
+@pytest.mark.parametrize('sql', [
+ 'SELECT * FROM tabl1 t1 WHERE t1.',
+ 'SELECT * FROM tabl1 t1, tabl2 t2 WHERE t1.',
+ 'SELECT * FROM "tabl1" t1 WHERE t1.',
+ 'SELECT * FROM "tabl1" t1, tabl2 t2 WHERE t1.',
+ ])
+def test_dot_suggests_cols_of_an_alias_where(sql):
+ suggestions = suggest_type(sql, sql)
+ assert sorted_dicts(suggestions) == sorted_dicts([
+ {'type': 'table', 'schema': 't1'},
+ {'type': 'view', 'schema': 't1'},
+ {'type': 'column', 'tables': [(None, 'tabl1', 't1')]},
+ {'type': 'function', 'schema': 't1'}])
+
+
def test_dot_col_comma_suggests_cols_or_schema_qualified_table():
suggestions = suggest_type('SELECT t1.a, t2. FROM tabl1 t1, tabl2 t2',
'SELECT t1.a, t2.')