mirror of
https://github.com/dbcli/pgcli.git
synced 2024-10-06 10:17:15 +03:00
Temporary hack for sqlparse crashing after AS
And a regression test.
This commit is contained in:
parent
beb9ceae94
commit
8d2265a65d
@ -133,7 +133,10 @@ def suggest_type(full_text, text_before_cursor):
|
||||
if full_text.startswith('\\i '):
|
||||
return (Path(),)
|
||||
|
||||
stmt = SqlStatement(full_text, text_before_cursor)
|
||||
try:
|
||||
stmt = SqlStatement(full_text, text_before_cursor)
|
||||
except (TypeError, AttributeError):
|
||||
return []
|
||||
|
||||
# Check for special commands and handle those separately
|
||||
if stmt.parsed:
|
||||
|
@ -55,6 +55,14 @@ def test_where_in_suggests_columns(expression):
|
||||
suggestions = suggest_type(expression, expression)
|
||||
assert set(suggestions) == cols_etc('tabl')
|
||||
|
||||
@pytest.mark.parametrize('expression', [
|
||||
'SELECT 1 AS ',
|
||||
'SELECT 1 FROM tabl AS ',
|
||||
])
|
||||
def test_after_as(expression):
|
||||
suggestions = suggest_type(expression, expression)
|
||||
assert set(suggestions) == set()
|
||||
|
||||
|
||||
def test_where_equals_any_suggests_columns_or_keywords():
|
||||
text = 'SELECT * FROM tabl WHERE foo = ANY('
|
||||
|
Loading…
Reference in New Issue
Block a user