diff options
author | koljonen <koljonen@outlook.com> | 2016-05-27 11:29:23 +0200 |
---|---|---|
committer | koljonen <koljonen@outlook.com> | 2016-05-27 11:29:23 +0200 |
commit | 843b859c1d505dcf512c1e3cd136fba79661f3be (patch) | |
tree | 137646dded57942794d97077131a0db0c2c99cae /tests | |
parent | 017bc3943fbe5685258d88439d29a30a11bd2559 (diff) |
Fix two casing issues with schemas
1. In 'SELECT * FROM Foo.', Foo was not recognized as foo.
2. In 'SELECT * FROM "Foo"', objects in Foo were not suggested.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_smart_completion_multiple_schemata.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_smart_completion_multiple_schemata.py b/tests/test_smart_completion_multiple_schemata.py index a8df8ce7..60781ffe 100644 --- a/tests/test_smart_completion_multiple_schemata.py +++ b/tests/test_smart_completion_multiple_schemata.py @@ -16,6 +16,9 @@ metadata = { 'Users': ['userid', 'username'], 'products': ['id', 'product_name', 'price'], 'shipments': ['id', 'address', 'user_id'] + }, + 'Custom': { + 'projects': ['projectid', 'name'] }}, 'functions': { 'public': [ @@ -26,6 +29,9 @@ metadata = { ['set_returning_func', 'OUT x INT', 'SETOF INT', False, False, True]], + 'Custom': [ + ['func4', '', '', False, False, False] + ] }, 'datatypes': { 'public': ['typ1', 'typ2'], @@ -81,6 +87,7 @@ def test_schema_or_visible_table_completion(completer, complete_event): Completion(text='func2', start_position=0, display_meta='function'), Completion(text='public', start_position=0, display_meta='schema'), Completion(text='custom', start_position=0, display_meta='schema'), + Completion(text='"Custom"', start_position=0, display_meta='schema'), Completion(text='users', start_position=0, display_meta='table'), Completion(text='"select"', start_position=0, display_meta='table'), Completion(text='orders', start_position=0, display_meta='table')]) @@ -169,6 +176,7 @@ def test_suggested_column_names_in_function(completer, complete_event): @pytest.mark.parametrize('text', [ + 'SELECT * FROM Custom.', 'SELECT * FROM custom.', 'SELECT * FROM "custom".', ]) @@ -193,6 +201,25 @@ def test_suggested_table_names_with_schema_dot(completer, complete_event, Completion(text='set_returning_func', start_position=start_pos, display_meta='function'), ]) +@pytest.mark.parametrize('text', [ + 'SELECT * FROM "Custom".', +]) +@pytest.mark.parametrize('use_leading_double_quote', [False, True]) +def test_suggested_table_names_with_schema_dot2(completer, complete_event, + text, use_leading_double_quote): + if use_leading_double_quote: + text += '"' + start_pos = -1 + else: + start_pos = 0 + + position = len(text) + result = completer.get_completions( + Document(text=text, cursor_position=position), complete_event) + assert set(result) == set([ + Completion(text='func4', start_position=start_pos, display_meta='function'), + Completion(text='projects', start_position=start_pos, display_meta='table') + ]) def test_suggested_column_names_with_qualified_alias(completer, complete_event): """ @@ -289,6 +316,7 @@ def test_table_names_after_from(completer, complete_event): Completion(text='func2', start_position=0, display_meta='function'), Completion(text='public', start_position=0, display_meta='schema'), Completion(text='custom', start_position=0, display_meta='schema'), + Completion(text='"Custom"', start_position=0, display_meta='schema'), Completion(text='users', start_position=0, display_meta='table'), Completion(text='orders', start_position=0, display_meta='table'), Completion(text='"select"', start_position=0, display_meta='table'), |