Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy as Sql #2174

Open
TimBailey-driva opened this issue May 2, 2024 · 6 comments
Open

Copy as Sql #2174

TimBailey-driva opened this issue May 2, 2024 · 6 comments
Labels
accepted 👍 bug Something isn't working

Comments

@TimBailey-driva
Copy link

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
image

image

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
@azmy60
Copy link
Contributor

azmy60 commented May 3, 2024

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 in getInsertQueryTests or make a new one

@azmy60 azmy60 added bug Something isn't working accepted 👍 labels May 3, 2024
@mcanepa
Copy link

mcanepa commented May 5, 2024

@azmy60 the same should apply to #1782

@rathboma
Copy link
Collaborator

@ellipsis-dev please implement

Copy link
Contributor

ellipsis-dev bot commented May 10, 2024

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.

@nsbradford
Copy link

hey sorry about this @rathboma, we're looking into it

ellipsis-dev bot added a commit that referenced this issue May 10, 2024
@JuanAraneta
Copy link

This is still failing in 4.3.1, is already being deployed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted 👍 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants