Apply every RENAME COLUMN in a multi-column MySQL ALTER#4495
Open
dimasfeb19 wants to merge 1 commit into
Open
Conversation
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Multi-column MySQL
ALTER TABLEstatements that use more than oneRENAME COLUMNonly had the first rename applied. Queries referencing the later renamed columns then failed code generation withcolumn "..." does not exist.The MySQL converter (
convertAlterTableStmt) returned aRenameColumnStmtas soon as it hit the firstRENAME COLUMNspec, 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 specsnote on that branch.This emits an
AT_RenameColumncommand for each rename spec, the same wayADD/DROP/MODIFY COLUMNalready 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