usql icon indicating copy to clipboard operation
usql copied to clipboard

Autocomplete for DDL commands

Open nineinchnick opened this issue 3 years ago • 4 comments

Implement autocomplete for DDL commands like CREATE, ALTER, and DROP.

nineinchnick avatar Mar 26 '21 21:03 nineinchnick

It is okay to see the implementation on #286 to create autocomplete for ALTER and DROP @nineinchnick ?

rubiagatra avatar Mar 15 '22 12:03 rubiagatra

@rubiagatra PRs are always welcome! Using the PR you mentioned as an example, one could attempt to translate more parts of https://github.com/postgres/postgres/blob/master/src/bin/psql/tab-complete.c#L1740 from C to Go.

nineinchnick avatar Mar 15 '22 14:03 nineinchnick

hi @nineinchnick just want ask some questions. I recently create #428 Do you want to complete CREATE first?

e.g

in psql

postgres=# CREATE
ACCESS METHOD        DATABASE             FOREIGN TABLE        MATERIALIZED VIEW    PUBLICATION          SERVER               TEMP                 TYPE                 VIEW
AGGREGATE            DOMAIN               FUNCTION             OPERATOR             ROLE                 STATISTICS           TEMPORARY            UNIQUE
CAST                 EVENT TRIGGER        GROUP                OR REPLACE           RULE                 SUBSCRIPTION         TEXT SEARCH          UNLOGGED
COLLATION            EXTENSION            INDEX                POLICY               SCHEMA               TABLE                TRANSFORM            USER
CONVERSION           FOREIGN DATA WRAPPER LANGUAGE             PROCEDURE            SEQUENCE             TABLESPACE           TRIGGER              USER MAPPING FOR

currently in usql

pg:postgres@localhost/test=> CREATE
DATABASE  SCHEMA    SEQUENCE  TABLE     VIEW      TEMPORARY

rubiagatra avatar Oct 18 '23 13:10 rubiagatra

usql works with many more SQL dialects than just PostgreSQL. It's easy to add all the keywords from psql to the autocompleter, but I haven't done that yet because they might be invalid in some databases and right now we only have one generic completer. Most of them are also rarely used.

I think ALTER statements might be more useful, and are also pretty common.

nineinchnick avatar Oct 18 '23 13:10 nineinchnick