dbcli / litecli

CLI for SQLite Databases with auto-completion and syntax highlighting
https://litecli.com
BSD 3-Clause "New" or "Revised" License
2.09k stars 68 forks source link

Enable completion suggestion after SELECT based on the tables #98

Open FreddieOliveira opened 3 years ago

FreddieOliveira commented 3 years ago

If you open the chinook db and run the following command

select artists.name,albums.title from artists,albums where artists.`ArtistId` = albums.`ArtistId`

litecli will only suggest completions for artist. and albums. after the where, but not after the select. That means, the artists.name,albums.title have to be typed characters by character without completion help.

zzl0 commented 3 years ago

Thanks for the feedback. There is a simple workaround for this.

First, you type something like this:

select * from from artists, albums <cursor>

Then, you go back to delete the * and start typing the fields that you are interested:

select artists.<cursor> from from artists, albums

Now you should get the auto suggestions.

Basically, you have to tell the CLI which tables you are going to use.FROM is a good hint.

We probably could extract the tables from a partial query like below:

select artists.

You could say that the part before . is the table name, but then we have to deal with below use case:

select `artists.
FreddieOliveira commented 3 years ago

Cool, the workaround worked, but I still think suggesting tables name for completion after typing select would be very handy.