dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
http://mycli.net
Other
11.32k stars 656 forks source link

How to stop premature syntax validation #1070

Open soumendrak opened 1 year ago

soumendrak commented 1 year ago

In the middle of writing a query, currently mycli checking the syntax and throwing an error.

For example:

database> select count(*) from users where account_id=112354
+----------+
| count(*) |
+----------+
| 1930403  |
+----------+
1 row in set
Time: 0.326s

Then I was in the middle of editing the above query

database> select user_id from users where account_id=112354 order by Exception in thread Thread-205:
Traceback (most recent call last):                                                       
  File "/usr/share/mycli/mycli/packages/parseutils.py", line 95, in extract_from_part    
    raise StopIteration                                                                  
StopIteration                                                                            

The above exception was the direct cause of the following exception:                     

Traceback (most recent call last):                                                                                                                                                                                                    
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3/dist-packages/prompt_toolkit/interface.py", line 865, in run
    completions = list(buffer.completer.get_completions(document, complete_event))
  File "/usr/share/mycli/mycli/sqlcompleter.py", line 258, in get_completions
    suggestions = suggest_type(document.text, document.text_before_cursor)
  File "/usr/share/mycli/mycli/packages/completion_engine.py", line 93, in suggest_type
    full_text, identifier)
  File "/usr/share/mycli/mycli/packages/completion_engine.py", line 203, in suggest_based_on_last_token
    return [{'type': 'column', 'tables': extract_tables(full_text)}]
  File "/usr/share/mycli/mycli/packages/parseutils.py", line 154, in extract_tables
    return list(extract_table_identifiers(stream))
  File "/usr/share/mycli/mycli/packages/parseutils.py", line 113, in extract_table_identifiers
    for item in token_stream:
RuntimeError: generator raised StopIteration

How to stop premature syntax validation and suggestions?