dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.

Home Page:http://mycli.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

test_auto_escaped_col_names fails with sqlparse 0.4.3

jfly opened this issue · comments

test/test_smart_completion_public_schema_only.py::test_auto_escaped_col_names fails when run under sqlparse 0.4.3, but passes when run under sqlparse 0.4.2:

Passes with sqlparse 0.4.2:

$ git checkout v1.26.1 && pip install -r requirements-dev.txt && pip install -e . && pip install 'sqlparse==0.4.2' && pytest test/test_smart_completion_public_schema_only.py::test_auto_escaped_col_names
test/test_smart_completion_public_schema_only.py .                                                                                                      [100%]

====================================================================== 1 passed in 0.01s ======================================================================

Fails with sqlparse 0.4.3:

$ git checkout v1.26.1 && pip install -r requirements-dev.txt && pip install -e . && pip install 'sqlparse==0.4.3' && pytest test/test_smart_completion_public_schema_only.py::test_auto_escaped_col_names
...
test/test_smart_completion_public_schema_only.py F                                                                                                      [100%]

========================================================================== FAILURES ===========================================================================
_________________________________________________________________ test_auto_escaped_col_names _________________________________________________________________

completer = <mycli.sqlcompleter.SQLCompleter object at 0x7fb732a8e1f0>, complete_event = <Mock id='140424805671888'>

    def test_auto_escaped_col_names(completer, complete_event):
        text = 'SELECT  from `select`'
        position = len('SELECT ')
        result = list(completer.get_completions(
            Document(text=text, cursor_position=position),
            complete_event))
>       assert result == [
            Completion(text='*', start_position=0),
            Completion(text='`ABC`', start_position=0),
            Completion(text='`insert`', start_position=0),
            Completion(text='id', start_position=0),
        ] + \
            list(map(Completion, completer.functions)) + \
            [Completion(text='`select`', start_position=0)] + \
            list(map(Completion, completer.keywords))
E       AssertionError: assert [Completion(t...CAT')])), ...] == [Completion(t...CAT')])), ...]
E         At index 23 diff: Completion(text='select', start_position=0, display=FormattedText([('', 'select')])) != Completion(text='`select`', start_position=0, display=FormattedText([('', '`select`')]))
E         Use -v to get more diff

test/test_smart_completion_public_schema_only.py:318: AssertionError
=================================================================== short test summary info ===================================================================
FAILED test/test_smart_completion_public_schema_only.py::test_auto_escaped_col_names - AssertionError: assert [Completion(t...CAT')])), ...] == [Completion(t...CAT')])), ...]
====================================================================== 1 failed in 0.06s ======================================================================

I dug a bit and this seems to be happening because of this commit andialbrecht/sqlparse@c1a597e that went out in sqlparse 0.4.3.

I'm not entirely sure if this is revealing a bug in mycli (should it be escaping table names like this if necessary?) or if this is a perfectly find change in behavior, and the test should just be updated to allow the new behavior.