Cell editor for textual insert statements and/or visual clues
See original GitHub issueFrustration There are a couple of scenarios that frustrate me when writing or editing INSERT SQL statements on tables with multiple attributes, probably because of the nature of SQL language itself, but tools like this are made, hopefully, to make our lifes easier 😄
Keep on reading, an example comes later.
Here are a couple of scenarios I’m thinking of:
- One scenario is when I have to fill all the records for an row or two or three, which is a recurring task from now and then, or I have to edit a SQL that I get from code or logs, or from a mate
- The other scenario, is when, for whatever reason, I have to copy data from one database table and I want to “paste” it in another database table and I want to edit it first (for example from production to test, or from a intermediate test db to dev, …)
Maybe this already exists in some other way, but I have not been able to find anything like it in any tool I’ve used before, although to be honest, I’ve been using DBeaver for several years and not used other tools for a while.
Here is the thing, what I would love to have is the ability to edit the values of the fields using a cell editor. So yes, for the first scenario it is easy to select on the table you want and then click on “Add new row” and then fill the fields over there… althought sometimes you have the INSERT text already from a console statement in some programming language and you just want to debug… so yes, you can do the insert and change text later… sort of would work… but not completely.
Anyway, here is the second scenario. There is no way for me to copy the data from a row or N rows from one database (assuming same table schema) and easily change the values before executing the insert if there are tons of columns.
What I would love is to have a cell editor for insert statements when you deal with insert statements in text or a clue in the editor that helps me realize if I’m going to edit the value of the wrong column. You can see my point with the following example. Imagine you have this insert statement:
Example
INSERT INTO thetable (E, N, G, H, I, J, M, O, P, Q, F, A, K, L, B, C, D)
VALUES ('a', NULL, 'c', 0, 322871, 'f', 43.2, 'h', 'this is a small text', 'j', NULL, NULL, 0, 0, 0, 0, 'q');
Imagine the values & types match and the insert is valid. Now… here is the problem I face… let’s imagine I want to manually, in the TEXT EDITOR, go and change the value for Q column.
Can you please do it? Copy that statement, and do it in DBeaver or other editor… I’ll wait…
I’m sure most people will start counting which position does Q holds in the column part of the insert query, and then count the same amount in the VALUES, and then change it… and that is… unfortunatelly super-frustrating and error prone. Takes time and it is easy to make a mistake. People has been doing it for decades, and it is a “flaw” of SQL itself for small inserts, because if you think of it as a dict of name = value, it would be more human friendly. Of course SQL is designed like that because it is more optimal for longer queries with more rows, no need to repeat rows, and it totally makes sense at that level… but for a human being it is very error-prone. But we are not going to change SQL language. Tools to the rescue.
Obviously in the real world, the column names would be longer, but I used single letters and changed alphabetical order to make my point more clear.
Solutions There are two possible solutions, which will aid the edition, as far as I can think of (maybe there are more).
Solution 1: use colors and add a tooltip Imagine I’m in the text editor in DBeaver, on top of the ‘f’ field, and a tooltip appears where I have the cursor telling me I’m editing “column M” or “column field_name”, plus, maybe, add a background color that highlights the text “M” from the insert.
This will allow me to move through the text and will probably eliminate the human error, it would be a better solution that not having any aid, but does not require creating any other interface.
Solution 2: cell editor Sometimes it would be handy to create something similar to the results grid that you get when you do a select, so that, all columns and values are mapped from the insert statement in a way that you can edit all fields there, and when you click on “Done” the text gets replaced automatically with the things you edited.
This is probably a feature that you need to know of and look for when you write code, and you would have to previously select the area of the INSERT statement in the text editor, and then right click and select “Edit using Grid/Cell editor” or something like that, BUT it would be awesome to have it.
Remarks I believe both solutions presented (using colors/tooltips and cell editor) are complementary to each other. It would be great to have both, but any of them would definitely do our lives easier every now and then.
I’m happy to make a quick and dirty concept/sketch, in paint, of both solutions if needed, but hopefully my point it is clear.
Thanks a lot if you read this far 😃
Awesome product!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top GitHub Comments
We could try 1st approach, e.g. highlight column name background. Similarly to how we do it for selected words.
Thank you for your idea!