Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ Features
--------
* Right-align numeric columns, and make the behavior configurable.
* Add completions for stored procedures.
* Offer completions on `CREATE TABLE ... LIKE`.


Bug Fixes
--------
* Better respect case when `keyword_casing` is `auto`.
* Let favorite queries contain special commands.


Bug Fixes
--------
* Render binary values more consistently as hex literals.


Expand Down
8 changes: 6 additions & 2 deletions mycli/packages/completion_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,12 @@ def suggest_based_on_last_token(
{"type": "alias", "aliases": aliases},
{"type": "keyword"},
]
elif (token_v.endswith("join") and isinstance(token, Token) and token.is_keyword) or (
token_v in ("copy", "from", "update", "into", "describe", "truncate", "desc", "explain")
elif (
(token_v.endswith("join") and isinstance(token, Token) and token.is_keyword)
or (token_v in ("copy", "from", "update", "into", "describe", "truncate", "desc", "explain"))
# todo: the create table regex fails to match on multi-statement queries, which
# suggests a bug above in suggest_type()
or (token_v == "like" and re.match(r'^\s*create\s+table\s', full_text, re.IGNORECASE))
):
schema = (identifier and identifier.get_parent_name()) or []

Expand Down
13 changes: 13 additions & 0 deletions test/test_smart_completion_public_schema_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,16 @@ def test_auto_case_heuristic(completer, complete_event):
'join',
'json',
]


def test_create_table_like_completion(completer, complete_event):
text = "CREATE TABLE foo LIKE ti"
position = len(text)
result = list(completer.get_completions(Document(text=text, cursor_position=position), complete_event))
assert [x.text for x in result] == [
'time_zone',
'time_zone_name',
'time_zone_transition',
'time_zone_leap_second',
'time_zone_transition_type',
]