FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Apply every RENAME COLUMN in a multi-column MySQL ALTER by dimasfeb19 · Pull Request #4495 · sqlc-dev/sqlc · GitHub

/ sqlc Public

Apply every RENAME COLUMN in a multi-column MySQL ALTER - #4495

Open
dimasfeb19 wants to merge 1 commit into
sqlc-dev:mainfrom
dimasfeb19:fix-mysql-multi-rename-column
Open

Apply every RENAME COLUMN in a multi-column MySQL ALTER#4495
dimasfeb19 wants to merge 1 commit into
sqlc-dev:mainfrom
dimasfeb19:fix-mysql-multi-rename-column

Conversation

Copy link
Copy Markdown

Multi-column MySQL ALTER TABLE statements that use more than one RENAME COLUMN only had the first rename applied. Queries referencing the later renamed columns then failed code generation with column "..." does not exist.

ALTER TABLE users
    RENAME COLUMN name TO display_name,
    RENAME COLUMN label TO display_label;

The MySQL converter (convertAlterTableStmt) returned a RenameColumnStmt as soon as it hit the first RENAME COLUMN spec, so the remaining specs in the same statement were never processed. There was already a // TODO: Returning here may be incorrect if there are multiple specs note on that branch.

This emits an AT_RenameColumn command for each rename spec, the same way ADD / DROP / MODIFY COLUMN already accumulate into the command list, and applies it in the catalog (reusing the existing rename logic). Single renames keep working as before.

Added an end-to-end test (ddl_alter_table_rename_column_multiple/mysql) that renames two columns in one statement and selects both.

Fixes #4493

convertAlterTableStmt returned on the first RENAME COLUMN spec, so any
further renames in the same ALTER TABLE were dropped and queries using
the later columns failed to compile. Emit an AT_RenameColumn command per
spec, like the other multi-spec actions, and apply it in the catalog.

Fixes sqlc-dev#4493
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MySQL: only the first RENAME COLUMN in a multi-column ALTER is applied when parsing goose migrations

1 participant


Back | FazBrowse Home | New Git URL