Copy as Sql
Describe the bug Wen I click "copy as sql" on a table row its generating the sql in column "alphabetical order" rather than "table order". It obviously doesnt matter from a SQL PoV, but feels weird to see the ids etc in the middle of the insert statement. Would this be easy to resolve?
To Reproduce Click "Copy as Sql", then paste
Expected behavior Generated SQL should be in table column order ie in the order they are displayed in the grid (& in the database)
CREATE TABLE
`statuses` (
`status_code` smallint NOT NULL,
`status_description` varchar(50) DEFAULT NULL,
`external_mappings` json DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`status_code`) USING BTREE
) ENGINE = InnoDB DEFAULT CHARSET = latin1
Screenshots / Gifs
Version Information (please complete the following information):
- OS: Ubuntu 22.04 LTS
- App Version: 4.3.1
- Database type and version: Mysql 8.0.35
Thanks for reporting! I can see this as a bug. It should be fairly easy to fix given that we've already shown table columns in the correct order.
Fix notes:
- might be related to
connection.getInsertQuery - check all databases
- tests in
runCommonTests-> change the queries ingetInsertQueryTestsor make a new one
@azmy60 the same should apply to #1782
@ellipsis-dev please implement
I'm sorry, but I ran out of time before I could complete the implementation plan. I was able to find where the connection.getInsertQuery and buildInsertQuery functions are defined and how they work. I also found where the tests in runCommonTests are located and how they are structured. However, I was not able to find where the TableInsert objects are created. This information is necessary to modify the buildInsertQuery function to generate SQL in the order of the columns as they appear in the table. I recommend continuing the investigation from this point.
[No tentative implementation steps.]
For more information about Ellipsis, check the documentation.
hey sorry about this @rathboma, we're looking into it
This is still failing in 4.3.1, is already being deployed?