fix(mysql)!: full MODIFY COLUMN support.#7562
Open
burnison wants to merge 1 commit intotobymao:mainfrom
Open
Conversation
The semantics of `MODIFY COLUMN` in MySQL are not the same as `ALTER COLUMN`, but have been treated so since tobymao#3189. The two expressions are fundamentally incompatible: ``` | MODIFY [COLUMN] col_name column_definition [FIRST | AFTER col_name] | ALTER [COLUMN] col_name { SET DEFAULT {literal | (expr)} | SET {VISIBLE | INVISIBLE} | DROP DEFAULT } ``` Most importantly, the `MODIFY COLUMN` syntax takes a full `column_definition` and column position. The actual execution behaviour of `MODIFY` does not actually merge the column definition, but completely redefines it. When deciding what approach to take for implementation, I evaluated 3 approaches: * Adding a `column_definition` to `AlterColumn`, but this would be parallel to the other attributes leading to surprising syntax. * Similarly, adding `constraints` to `AlterColumn`, which, again, would lead to surprising, inconsistent outcomes. * This implementation, a dedicated `ModifyColumn`, which changes existing `MODIFY COLUMN` deployments that depend on `AlterColumn`. This breaking change are defensible, however, in that `MODIFY COLUMN c DROP DEFAULT` isn't valid syntax in MySQL, so the behaviour of existing deployments would likely be questionable.
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.
The semantics of
MODIFY COLUMNin MySQL are not the same asALTER COLUMN, but have been treated so since #3189. The twoALTER TABLEexpressions are fundamentally incompatible:Most importantly, the
MODIFY COLUMNsyntax takes a fullcolumn_definitionand column position. The actual execution behaviour ofMODIFYdoes not merge the column definition, but completely redefines it.When deciding what approach to take for implementation, I evaluated 3 approaches:
Adding a
column_definitiontoAlterColumn, but this would be parallel to the other attributes leading to surprising syntax.Similarly, adding
constraintstoAlterColumn, which, again, would lead to surprising, inconsistent outcomes.This implementation, a dedicated
ModifyColumn, which potentially breaks existingMODIFY COLUMNdeployments that might depend on it parsing toAlterColumn.This breaking change is defensible, however, in that
MODIFY COLUMN c DROP DEFAULTisn't valid syntax in MySQL. I'm led to believe the behaviour of existing deployments would likely be questionable if not broken (example: I had been working around it for more than a year by rewriting toADD COLUMN).