fix(parser-sql): Reflect ALTER/MODIFY/CHANGE COLUMN in after schema#183
Merged
Conversation
The ALTER TABLE handler ignored AlterColumn (PostgreSQL ALTER COLUMN ... TYPE / SET|DROP NOT NULL), ModifyColumn / ChangeColumn (MySQL), and RenameConstraint, emitting only an "unsupported" warning. Type changes, NOT NULL toggles, and column renames never reached the after schema, so relune review silently passed dangerous migrations and the ERD showed stale types. Add explicit arms for all four operations: MODIFY/CHANGE fully redefine the column (type, nullability, comment, inline UNIQUE/FK) while only adding primary-key membership, and PK columns stay NOT NULL. CHANGE reuses the RENAME COLUMN propagation so local FK/index columns and incoming FK targets follow the rename. Share column-option and data-type parsing with CREATE TABLE, and add per-dialect regression tests covering type narrowing, nullability, renames, enum repopulation, inline constraints, and unknown-target diagnostics.
Code Metrics Report
Details | | main (3b356ee) | #183 (8367214) | +/- |
|---------------------|----------------|----------------|--------|
+ | Coverage | 94.4% | 94.4% | +0.0% |
| Files | 100 | 100 | 0 |
| Lines | 36858 | 37038 | +180 |
+ | Covered | 34801 | 34973 | +172 |
+ | Test Execution Time | 3m28s | 1m33s | -1m55s |Code coverage of files in pull request scope (85.2% → 87.5%)
Reported by octocov |
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.
Summary
relune reviewand the ERD seeALTER TABLE ALTER/MODIFY/CHANGE COLUMNandRENAME CONSTRAINTinstead of dropping them with an "unsupported" warning, so type narrowing, NOT NULL toggles, and column renames now reach the after schema.MODIFY/CHANGEfully redefine a column (type, nullability, comment, inlineUNIQUE/FOREIGN KEY); primary-key membership is only added (never stripped) and PK columns stay NOT NULL.ALTER COLUMN ... TYPE / SET|DROP NOT NULLandRENAME CONSTRAINT(PK/FK/index names) are now applied, andCHANGEreuses theRENAME COLUMNpropagation so FK/index columns follow the rename.Changes
AlterColumn,ModifyColumn,ChangeColumn, andRenameConstraintarms to the ALTER TABLE handler so type/NULL/rename edits and constraint renames mutate the parsed schema, with unknown-column/constraint diagnostics on miss.MODIFY/CHANGEas full column redefinitions (type, nullability, comment, inlineUNIQUE/FOREIGN KEY) that only add PK membership and keep PK columns NOT NULL, clearing cached enum values so the MySQL enum pass repopulates them;CHANGEshares theRENAME COLUMNpropagation to update local FK/index columns and incoming FK targets.CREATE TABLEand add per-dialect regression tests covering type narrowing, nullability, renames, enum repopulation, inline constraints, and unknown-target diagnostics.