Bug 1376124

Summary: mycli broken with python3-sqlparse-0.2.1-1.fc24
Product: [Fedora] Fedora Reporter: Dick Marinus <dick>
Component: mycliAssignee: Terje Røsten <terje.rosten>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: fale, terje.rosten
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: mycli-1.8.0-2.fc25 mycli-1.8.0-2.fc24 mycli-1.8.0-2.fc23 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-27 00:38:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dick Marinus 2016-09-14 18:42:24 UTC
Description of problem:

Version-Release number of selected component (if applicable): mycli-1.8.0-1.fc24.noarch


How reproducible:

Steps to Reproduce:
1. start mycli
2. enter a query, type "select " and a exception is thrown
3. dnf downgrade mycli-1.8.0-1.fc24.noarch and "select " shows completion

Upstream issue:
https://github.com/dbcli/mycli/issues/302

Comment 1 Dick Marinus 2016-09-17 13:39:00 UTC
I've written a patch for sqlparse 0.2 support:

https://github.com/meeuw/mycli/commit/895e109ca169e240e0f26e087b93c3b47df2232a.patch

Comment 2 Terje Røsten 2016-09-17 16:50:30 UTC
Great, works fine! Thanks!

Comment 3 Fedora Update System 2016-09-18 06:41:39 UTC
mycli-1.8.0-2.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-d7d6e78421

Comment 4 Fedora Update System 2016-09-18 06:41:47 UTC
mycli-1.8.0-2.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-b9b07582fe

Comment 5 Fedora Update System 2016-09-18 06:41:52 UTC
mycli-1.8.0-2.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2016-dbf69e17ce

Comment 6 Dick Marinus 2016-09-18 12:26:22 UTC
I've did some more testing and there're more modifications required for sqlparse 0.2.1..

https://github.com/meeuw/mycli/commit/d14ec3d92d808ddca3eeeb8e9c2ed22e3ed87c1b.patch

Steps to reproduce:
1. start mycli
2. USE `mysql`
3. SELECT FROM user
4. Change to SELECT user FROM user (triggers auto completion)

Results in:
Exception in thread Thread-49:
Traceback (most recent call last):                                   
  File "/usr/lib64/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()                                                       
  File "/usr/lib64/python3.5/threading.py", line 862, in run         
    self._target(*self._args, **self._kwargs)                        
  File "/usr/lib/python3.5/site-packages/prompt_toolkit/interface.py", line 759, in run
    completions = list(buffer.completer.get_completions(document, complete_event))
  File "/home/meeuw/git/mycli/mycli/sqlcompleter.py", line 247, in get_completions                                                           
    suggestions = suggest_type(document.text, document.text_before_cursor)
  File "/home/meeuw/git/mycli/mycli/packages/completion_engine.py", line 86, in suggest_type
    full_text, identifier)
  File "/home/meeuw/git/mycli/mycli/packages/completion_engine.py", line 216, in suggest_based_on_last_token
    return [{'type': 'column', 'tables': extract_tables(full_text)},
  File "/home/meeuw/git/mycli/mycli/packages/parseutils.py", line 154, in extract_tables
    return list(extract_table_identifiers(stream))
  File "/home/meeuw/git/mycli/mycli/packages/parseutils.py", line 113, in extract_table_identifiers
    for item in token_stream: 
  File "/home/meeuw/git/mycli/mycli/packages/parseutils.py", line 79, in extract_from_part
    if is_subselect(item):    
  File "/home/meeuw/git/mycli/mycli/packages/parseutils.py", line 67, in is_subselect
    if not parsed.is_group(): 
TypeError: 'bool' object is not callable

Comment 7 Terje Røsten 2016-09-18 19:11:08 UTC
I am not able to reproduce or I am misunderstanding something:

USE mysql;
SELECT user FROM use<tab-to-complete> works fine.

You tried something more complex?

Comment 8 Dick Marinus 2016-09-18 19:37:53 UTC
Nope, it breaks when you try to complete the "column" user, not the "table" user:
USE mysql
SELECT u<tab-to-complete> FROM user;

But I haven't tried this using the RPM you've build...

Comment 9 Terje Røsten 2016-09-18 20:54:17 UTC
Seems to work here:

USE mysql;

SELECT <tab-to-complete> FROM user;

brings all columns in mysql.user.

Even

 select `User`,<tab-to-complete> FROM `user`;

works, strange.

Versions:

$ rpm -qa mycli python3-sqlparse
mycli-1.8.0-2.fc23.noarch
python3-sqlparse-0.2.1-1.fc23.noarch

Comment 10 Fedora Update System 2016-09-19 04:20:05 UTC
mycli-1.8.0-2.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-d7d6e78421

Comment 11 Fedora Update System 2016-09-19 04:22:37 UTC
mycli-1.8.0-2.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-b9b07582fe

Comment 12 Fedora Update System 2016-09-19 05:22:45 UTC
mycli-1.8.0-2.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-dbf69e17ce

Comment 13 Fedora Update System 2016-09-27 00:38:47 UTC
mycli-1.8.0-2.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.

Comment 14 Fedora Update System 2016-09-27 03:52:08 UTC
mycli-1.8.0-2.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2016-09-27 14:51:28 UTC
mycli-1.8.0-2.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.