From b39e828f62a80db707e8a9355507c9ebdaccb7f5 Mon Sep 17 00:00:00 2001 From: Dick Marinus Date: Tue, 13 Aug 2019 20:43:20 +0200 Subject: [PATCH] Revert "sqlparse updated to 0.3.0, causing breakage even thought it is fine" This reverts commit c11dc24e94b3605091d34ae1dd4248e641fa2ccc. Revert "Update changelog.md" This reverts commit e75def918abdc3def8bcc35c5524f4bbef932958. Revert "Update AUTHORS" This reverts commit 34148aae606176fa32b808c47ef634245a6d56ce. Revert "fix unit tests, hard depend on 0.3.0" This reverts commit 3acecd9d69e87333c1887dc2e797fa20300b9a44. Revert "add and fix order by keyword test" This reverts commit 4bf93f76ec75e4a7029639749f6fd4b37830cbea. --- changelog.md | 1 - mycli/AUTHORS | 1 - mycli/packages/completion_engine.py | 4 ++-- setup.py | 2 +- test/test_completion_engine.py | 6 ------ 5 files changed, 3 insertions(+), 11 deletions(-) diff --git a/changelog.md b/changelog.md index f3b3f502..b873f191 100644 --- a/changelog.md +++ b/changelog.md @@ -15,7 +15,6 @@ Bug Fixes: * Fix favorites queries being loaded/stored only from/in default config file and not --myclirc (Thanks: [Matheus Rosa]) * Fix automatic vertical output with native syntax style (Thanks: [Thomas Roten]). * Update `cli_helpers` version, this will remove quotes from batch output like the official client (Thanks: [Dick Marinus]) -* Update `setup.py` to no longer require `sqlparse` to be less than 0.3.0 as that just came out and there are no notable changes. ([VVelox]) * workaround for ConfigObj parsing strings containing "," as lists (Thanks: [Mike Palandra]) Internal: diff --git a/mycli/AUTHORS b/mycli/AUTHORS index ae1fb08a..22ed896e 100644 --- a/mycli/AUTHORS +++ b/mycli/AUTHORS @@ -64,7 +64,6 @@ Contributors: * Yang Zou * Angelo Lupo * Aljosha Papsch - * Zane C. Bowers-Hadley * Mike Palandra Creator: diff --git a/mycli/packages/completion_engine.py b/mycli/packages/completion_engine.py index bea79274..2426f30c 100644 --- a/mycli/packages/completion_engine.py +++ b/mycli/packages/completion_engine.py @@ -84,7 +84,7 @@ def suggest_type(full_text, text_before_cursor): # Be careful here because trivial whitespace is parsed as a statement, # but the statement won't have a first token tok1 = statement.token_first() - if tok1 and (tok1.value == 'source' or tok1.value.startswith('\\')): + if tok1 and tok1.value in ['\\', 'source']: return suggest_special(text_before_cursor) last_token = statement and statement.token_prev(len(statement.tokens))[1] or '' @@ -199,7 +199,7 @@ def suggest_based_on_last_token(token, text_before_cursor, full_text, identifier # We're probably in a function argument list return [{'type': 'column', 'tables': extract_tables(full_text)}] - elif token_v in ('set', 'order by', 'distinct'): + elif token_v in ('set', 'by', 'distinct'): return [{'type': 'column', 'tables': extract_tables(full_text)}] elif token_v == 'as': # Don't suggest anything for an alias diff --git a/setup.py b/setup.py index 3081f19c..1dc1d1a8 100755 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ 'Pygments >= 1.6', 'prompt_toolkit>=2.0.6', 'PyMySQL >= 0.9.2', - 'sqlparse>=0.3.0,<0.4.0', + 'sqlparse>=0.2.2,<0.3.0', 'configobj >= 5.0.5', 'cryptography >= 1.0.0', 'cli_helpers[styles] > 1.1.0', diff --git a/test/test_completion_engine.py b/test/test_completion_engine.py index 98b89e1e..0e814795 100644 --- a/test/test_completion_engine.py +++ b/test/test_completion_engine.py @@ -523,9 +523,3 @@ def test_after_as(expression): def test_source_is_file(expression): suggestions = suggest_type(expression, expression) assert suggestions == [{'type': 'file_name'}] - - -def test_order_by(): - text = 'select * from foo order by ' - suggestions = suggest_type(text, text) - assert suggestions == [{'tables': [(None, 'foo', None)], 'type': 'column'}]