Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete not working for "events" table if unquoted #954

Open
3 tasks done
owst opened this issue Oct 11, 2018 · 1 comment
Open
3 tasks done

Autocomplete not working for "events" table if unquoted #954

owst opened this issue Oct 11, 2018 · 1 comment
Labels

Comments

@owst
Copy link
Contributor

owst commented Oct 11, 2018

Description

We have a table named events. Autocomplete doesn't work in query involving this table (at least for a JOIN condition and a SELECT column), unless I quote the table name.

Reproduction

postgres@localhost:postgres> CREATE TABLE events (description text);
CREATE TABLE
Time: 0.012s

Then

postgres@localhost:postgres> SELECT descri* FROM events; 

Cursor at *, having just typed i the completions I see are:

pg_describe_object()                    function  
col_description()                       function  
obj_description()                       function  
shobj_description()                     function  
binary_upgrade_set_record_init_privs()  function  
describe                                keyword   

If I change s/events/"events"/ and retype the i:

postgres@localhost:postgres> SELECT descri FROM "events"; 

then I see:

description                             column    
pg_describe_object()                    function  
col_description()                       function  
obj_description()                       function  
shobj_description()                     function  
binary_upgrade_set_record_init_privs()  function  
describe                                keyword   

as expected.

I'm using Vi-mode, if that matters (I don't think it does). Is this expected, or is there something special about the table name events? Interestingly, if I call the table not_events I don't need to quote the table name for the columns to autocomplete.

Your environment

  • Please provide your OS and version information.
    Ubuntu 16.04 x64
  • Please provide your CLI version.
> pgcli --version
Version: 2.0.0
  • What is the output of pip freeze command.
(pgcli_issue) > pip freeze
backports.csv==1.0.6
cli-helpers==1.0.2
Click==7.0
configobj==5.0.6
humanize==0.5.1
pgcli==2.0.0
pgspecial==1.11.2
prompt-toolkit==2.0.5
psycopg2==2.7.5
Pygments==2.2.0
setproctitle==1.1.10
six==1.11.0
sqlparse==0.2.4
tabulate==0.8.2
terminaltables==3.1.0
wcwidth==0.1.7
@owst
Copy link
Contributor Author

owst commented Apr 4, 2020

Having dug into this, sqlparse is (incorrectly, for Postgres) treating events as a keyword, rather than an identifier. I've followed up on a promising-sounding PR that would allow us to use sqlparse in "Postgres" mode, where events wouldn't be considered a keyword, but for now, I don't see an easy way to fix this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants