1
1
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:
Joakim Koljonen 2016-08-23 20:14:00 +02:00
parent beb9ceae94
commit 8d2265a65d
No known key found for this signature in database
GPG Key ID: AF0327B5131CD164
2 changed files with 12 additions and 1 deletions

View File

@ -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:

View File

@ -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('