question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autocompleter explodes on last character from any valid SQL command or space for any other text

See original GitHub issue

After starting pgcli typing any SQL command will blow auto-completer when last character is pressed. Or if any text is typed, it will blow after pressing space:

selectException in thread Thread-6:
Traceback (most recent call last):      
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()                          
  File "/usr/lib/python3.5/threading.py", line 862, in runs-mode                                                                                                             
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.5/site-packages/prompt_toolkit/interface.py", line 835, in run
    completions = list(buffer.completer.get_completions(document, complete_event))
  File "/usr/lib/python3.5/site-packages/pgcli/pgcompleter.py", line 332, in get_completions
    suggestions = suggest_type(document.text, document.text_before_cursor)
  File "/usr/lib/python3.5/site-packages/pgcli/packages/sqlcompletion.py", line 104, in suggest_type
    stmt = SqlStatement(full_text, text_before_cursor)
  File "/usr/lib/python3.5/site-packages/pgcli/packages/sqlcompletion.py", line 66, in __init__
    self.identifier = parse_partial_identifier(word_before_cursor)
  File "/usr/lib/python3.5/site-packages/pgcli/packages/parseutils.py", line 299, in parse_partial_identifier
    elif p.token_next_match(0, Error, '"'):
AttributeError: 'Statement' object has no attribute 'token_next_match'

After this there’s no more auto-completer and it doesn’t explode anymore. Another example to show it’s the same for any valid SQL:

dropException in thread Thread-4:
Traceback (most recent call last):       
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()                           
  File "/usr/lib/python3.5/threading.py", line 862, in runs-mode                                                                                                             
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.5/site-packages/prompt_toolkit/interface.py", line 835, in run
    completions = list(buffer.completer.get_completions(document, complete_event))
  File "/usr/lib/python3.5/site-packages/pgcli/pgcompleter.py", line 332, in get_completions
    suggestions = suggest_type(document.text, document.text_before_cursor)
  File "/usr/lib/python3.5/site-packages/pgcli/packages/sqlcompletion.py", line 104, in suggest_type
    stmt = SqlStatement(full_text, text_before_cursor)
  File "/usr/lib/python3.5/site-packages/pgcli/packages/sqlcompletion.py", line 66, in __init__
    self.identifier = parse_partial_identifier(word_before_cursor)
  File "/usr/lib/python3.5/site-packages/pgcli/packages/parseutils.py", line 299, in parse_partial_identifier
    elif p.token_next_match(0, Error, '"'):
AttributeError: 'Statement' object has no attribute 'token_next_match'

$ pgcli --version Version: 1.1.0

Running on Archlinux. If you need any other information don’t hesitate to request it.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
klardotshcommented, Sep 6, 2016

Creating a virtualenv and pip-installing pgcli after uninstalling the AUR package “solves” the issue, but will require a shell script wrapper to switch to that venv every time I want to use pgcli. Doable, but far from optimal.

I’ll look into patching up the PKGBUILD when I have some spare time, for us Arch folk.

1reaction
amjithcommented, Sep 3, 2016

Please upgrade to v1.2.0.

pip install -U pgcli

This issue is addressed in the new version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Autocomplete deletes last character from words sometimes
When I hit [tab][tab] sometimes I get a list of words begining with the typed word, other times it just deletes the last...
Read more >
How to get autocomplete in jupyter notebook without using tab?
I developed a Jupyter Notebook Extension based on TabNine which provides code auto-completion based on Deep Learning. Here's the Github link of ...
Read more >
Searching a string for the last occurrence of a given string
Here CHARINDEX is searching the reversed string to find the position of the last '\' character. The RIGHT function is then used to...
Read more >
AutoCompleteTextView - Android Developers
This view is invisible, and it doesn't take any space for layout purposes. ... Gets the text colors for the different states (normal,...
Read more >
The STRING_SPLIT function in SQL Server
The purpose of this built-in string function is to convert string arrays to columns which are separated by any separator. The below figure ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found