little-brother / sqlite-gui

Lightweight SQLite editor for Windows
GNU General Public License v2.0
1.07k stars 51 forks source link

Add drop-down list with foreign keys in the GUIs (Feature request) #153

Closed SilvioGrosso closed 4 months ago

SilvioGrosso commented 5 months ago

Hello @little-brother

With many softwares (Db Browser for SQLite, Sqlitestudio, Dbeaver, LibreOffice Calc) whenever you have a foreign key there appears by default, in the GUIs, a drop-down list with all the items you are allowed to select. It is quite useful whenever there are plenty of them, therefore you can't remember all of them by heart.

For instance, suppose we create 2 tables:

create table articles( id integer not null, fruit text primary key );

insert into articles (id, fruit) values (1, 'apple'), (2, 'kiwi'), (3, 'pear');

create table buyers ( id integer primary key, buyer text, fruit text, price integer, FOREIGN KEY (fruit) REFERENCES articles(fruit) );

insert into buyers (id, buyer, fruit, price) values (1, 'Silvio', 'apple', 1500), (2, 'Marco', 'pear', 1600), (3, 'Stefano', 'kiwi', 1800);

Now, I want to insert, through the GUIs, a new line (4°) in the table buyers. The items (fruit) allowed are: apple - pear - kiwi

Here is what occurs with Db Browser for SQLite:

image

I suppose it would be quite difficult to add (code) an option to get a drop-down like this in sqlite-gui This when: pragma foreign-keys = ON (in the settings)

However, I am wondering whether it would be possible to add an option with such a list in here (edit value window)?

image

little-brother commented 5 months ago

Could you check "Add row"-dialog in sqlite-x (use Ctrl + Space to show dropdown list) ? Is it what you asked for?

SilvioGrosso commented 5 months ago

Hello @little-brother

In all truth, I recall having this feature in some old versions of sqlite-gui. To make it short, I didn't remember the shortcut to trigger it and where it was supposed to work

However, now, I have tried but it does not work (ctr+space) with cursor in fruit image

EDIT: tried this shortcut also into the value editor window (sqlite-gui.1.8.2-x64-inja on Windows 10 - 64 bit)

little-brother commented 5 months ago

sqlite-gui doesn't have it yet. Check sqlite-x. It's another my small project for SQLite where I test some features (cause its code is much simpler).

SilvioGrosso commented 5 months ago

Yep. it works fine on sqlite-x. The drop-down list appears like in the other softwares.

I have noticed it is also possible to hide and move columns, within a table, in the GUIs, which is quite neat. Not to mention, the dark theme :smile:

Is this GUIs a QT application?

little-brother commented 5 months ago

Not to mention, the dark theme

sqlite-gui has many forms. So there is a lot of work to colorize them all :(

Is this GUIs a QT application?

Nope. It uses WinAPI as all another my projects.

little-brother commented 4 months ago

Done. Use Ctrl + Space to view suggestions.