summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2022-08-13 19:24:06 -0700
committerGitHub <noreply@github.com>2022-08-13 19:24:06 -0700
commit4bc380ec4acac0b389d2d62d806a2dfe20ec15af (patch)
treed36cd6f8147ca426692cd34c56778833bab867c7
parentdf45000a3486f9bb35ff494a8b41f191992e9d5a (diff)
parente882167e6d544793ab2a34ef702aa1fdcf83cb65 (diff)
Merge pull request #1006 from emorozov/master
Fix autocomplete exception on quoted string.
-rw-r--r--mycli/packages/completion_engine.py2
-rw-r--r--test/test_completion_engine.py7
2 files changed, 9 insertions, 0 deletions
diff --git a/mycli/packages/completion_engine.py b/mycli/packages/completion_engine.py
index c7db06c..8718204 100644
--- a/mycli/packages/completion_engine.py
+++ b/mycli/packages/completion_engine.py
@@ -129,6 +129,8 @@ def suggest_based_on_last_token(token, text_before_cursor, full_text, identifier
prev_keyword, text_before_cursor = find_prev_keyword(text_before_cursor)
return suggest_based_on_last_token(prev_keyword, text_before_cursor,
full_text, identifier)
+ elif token is None:
+ return [{'type': 'special'}]
else:
token_v = token.value.lower()
diff --git a/test/test_completion_engine.py b/test/test_completion_engine.py
index 8b06ed3..d02124f 100644
--- a/test/test_completion_engine.py
+++ b/test/test_completion_engine.py
@@ -542,7 +542,14 @@ def test_favorite_name_suggestion(expression):
suggestions = suggest_type(expression, expression)
assert suggestions == [{'type': 'favoritequery'}]
+
def test_order_by():
text = 'select * from foo order by '
suggestions = suggest_type(text, text)
assert suggestions == [{'tables': [(None, 'foo', None)], 'type': 'column'}]
+
+
+def test_quoted_where():
+ text = "'where i=';"
+ suggestions = suggest_type(text, text)
+ assert suggestions == [{'type': 'special'}]