From 13f3af72c3a65f88a8dbbc53d4619bbcb8ec67e7 Mon Sep 17 00:00:00 2001 From: Iryna Cherniavska Date: Mon, 19 Jan 2015 17:03:44 -0800 Subject: ON keyword now suggests tables and aliases on the right side of equal sign also. --- tests/test_smart_completion.py | 20 ++++++++++++++++++++ tests/test_sqlcompletion.py | 14 ++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/test_smart_completion.py b/tests/test_smart_completion.py index b306b36a..425344b9 100644 --- a/tests/test_smart_completion.py +++ b/tests/test_smart_completion.py @@ -197,6 +197,16 @@ def test_suggested_aliases_after_on(completer, complete_event): Completion(text='u', start_position=0), Completion(text='o', start_position=0)]) +def test_suggested_aliases_after_on_right_side(completer, complete_event): + text = 'SELECT u.name, o.id FROM users u JOIN orders o ON o.user_id = ' + position = len('SELECT u.name, o.id FROM users u JOIN orders o ON o.user_id = ') + result = set(completer.get_completions( + Document(text=text, cursor_position=position), + complete_event)) + assert set(result) == set([ + Completion(text='u', start_position=0), + Completion(text='o', start_position=0)]) + def test_suggested_tables_after_on(completer, complete_event): text = 'SELECT users.name, orders.id FROM users JOIN orders ON ' position = len('SELECT users.name, orders.id FROM users JOIN orders ON ') @@ -207,6 +217,16 @@ def test_suggested_tables_after_on(completer, complete_event): Completion(text='users', start_position=0), Completion(text='orders', start_position=0)]) +def test_suggested_tables_after_on_right_side(completer, complete_event): + text = 'SELECT users.name, orders.id FROM users JOIN orders ON orders.user_id = ' + position = len('SELECT users.name, orders.id FROM users JOIN orders ON orders.user_id = ') + result = set(completer.get_completions( + Document(text=text, cursor_position=position), + complete_event)) + assert set(result) == set([ + Completion(text='users', start_position=0), + Completion(text='orders', start_position=0)]) + def test_table_names_after_from(completer, complete_event): text = 'SELECT * FROM ' position = len('SELECT * FROM ') diff --git a/tests/test_sqlcompletion.py b/tests/test_sqlcompletion.py index 949321e7..df0cdc7c 100644 --- a/tests/test_sqlcompletion.py +++ b/tests/test_sqlcompletion.py @@ -127,3 +127,17 @@ def test_on_suggests_tables(): 'select abc.x, bcd.y from abc join bcd on ') assert category == 'tables-or-aliases' assert set(scope) == set(['abc', 'bcd']) + +def test_on_suggests_aliases_right_side(): + category, scope = suggest_type( + 'select a.x, b.y from abc a join bcd b on a.id = ', + 'select a.x, b.y from abc a join bcd b on a.id = ') + assert category == 'tables-or-aliases' + assert set(scope) == set(['a', 'b']) + +def test_on_suggests_tables_right_side(): + category, scope = suggest_type( + 'select abc.x, bcd.y from abc join bcd on ', + 'select abc.x, bcd.y from abc join bcd on ') + assert category == 'tables-or-aliases' + assert set(scope) == set(['abc', 'bcd']) -- cgit v1.2.3