diff options
author | Owen Stephens <owen@owenstephens.co.uk> | 2019-10-12 16:19:04 +0100 |
---|---|---|
committer | Owen Stephens <owen@owenstephens.co.uk> | 2019-10-12 16:19:15 +0100 |
commit | b401b16d9a4332b3af64a5ce12c8ce6727885917 (patch) | |
tree | 3427d1d05143da6466ecff5e9c4caae8a0014a7b /tests | |
parent | d5cdd2ad4ea5c70dae766f2e00a71510e9c76b58 (diff) |
Take account of table aliases when completing function args (#1048)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_sqlcompletion.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/test_sqlcompletion.py b/tests/test_sqlcompletion.py index ed647fc6..c5ef7b7d 100644 --- a/tests/test_sqlcompletion.py +++ b/tests/test_sqlcompletion.py @@ -101,10 +101,14 @@ def test_where_equals_any_suggests_columns_or_keywords(): assert set(suggestions) == cols_etc("tabl", last_keyword="WHERE") -def test_lparen_suggests_cols(): +def test_lparen_suggests_cols_and_funcs(): suggestion = suggest_type("SELECT MAX( FROM tbl", "SELECT MAX(") assert set(suggestion) == set( - [Column(table_refs=((None, "tbl", None, False),), qualifiable=True)] + [ + Column(table_refs=((None, "tbl", None, False),), qualifiable=True), + Function(schema=None), + Keyword("("), + ] ) @@ -282,6 +286,23 @@ def test_distinct_and_order_by_suggestions_with_alias_given(text, text_before): ) +def test_function_arguments_with_alias_given(): + suggestions = suggest_type("SELECT avg(x. FROM tbl x, tbl2 y", "SELECT avg(x.") + + assert set(suggestions) == set( + [ + Column( + table_refs=(TableReference(None, "tbl", "x", False),), + local_tables=(), + qualifiable=False, + ), + Table(schema="x"), + View(schema="x"), + Function(schema="x"), + ] + ) + + def test_col_comma_suggests_cols(): suggestions = suggest_type("SELECT a, b, FROM tbl", "SELECT a, b,") assert set(suggestions) == set( |