mirror of
https://github.com/dbcli/pgcli.git
synced 2024-11-10 01:24:34 +03:00
Merge pull request #641 from dbcli/darikg/keywords-after-alter
Suggest keywords after ALTER
This commit is contained in:
commit
b07d63be4c
@ -460,6 +460,8 @@ def suggest_based_on_last_token(token, stmt):
|
|||||||
if not schema:
|
if not schema:
|
||||||
suggestions.append(Schema())
|
suggestions.append(Schema())
|
||||||
return tuple(suggestions)
|
return tuple(suggestions)
|
||||||
|
elif token_v == 'alter':
|
||||||
|
return (Keyword(),)
|
||||||
elif token.is_keyword:
|
elif token.is_keyword:
|
||||||
# token is a keyword we haven't implemented any special handling for
|
# token is a keyword we haven't implemented any special handling for
|
||||||
# go backwards in the query until we find one we do recognize
|
# go backwards in the query until we find one we do recognize
|
||||||
|
@ -999,3 +999,10 @@ def test_keyword_casing_upper(keyword_casing, expected, texts):
|
|||||||
Document(text=text, cursor_position=len(text)), complete_event)
|
Document(text=text, cursor_position=len(text)), complete_event)
|
||||||
assert expected in [cpl.text for cpl in completions]
|
assert expected in [cpl.text for cpl in completions]
|
||||||
|
|
||||||
|
|
||||||
|
def test_keyword_after_alter(completer):
|
||||||
|
sql = 'ALTER TABLE users ALTER '
|
||||||
|
expected = Completion('COLUMN', start_position=0, display_meta='keyword')
|
||||||
|
completions = completer.get_completions(
|
||||||
|
Document(text=sql, cursor_position=len(sql)), complete_event)
|
||||||
|
assert expected in set(completions)
|
||||||
|
@ -762,3 +762,9 @@ def test_handle_unrecognized_kw_generously():
|
|||||||
assert expected in set(suggestions)
|
assert expected in set(suggestions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('sql', [
|
||||||
|
'ALTER ',
|
||||||
|
'ALTER TABLE foo ALTER ',
|
||||||
|
])
|
||||||
|
def test_keyword_after_alter(sql):
|
||||||
|
assert Keyword() in set(suggest_type(sql, sql))
|
||||||
|
Loading…
Reference in New Issue
Block a user