Add INVISIBLE column constraint for MySQL.#7510
Merged
VaggelisD merged 2 commits intotobymao:mainfrom Apr 17, 2026
Merged
Conversation
MySQL 8.0.23 introduced invisible columns, declared with the `INVISIBLE` keyword in column definitions. Until now, sqlglot could parse `ALTER TABLE ... ALTER COLUMN ... SET INVISIBLE` (PR tobymao#4809) and `ALTER TABLE ... ALTER INDEX ... INVISIBLE` (PR tobymao#4800), but the keyword was not recognized in column definitions. This meant `CREATE TABLE t (c INT INVISIBLE)` and `ALTER TABLE t ADD COLUMN c INT INVISIBLE` both failed to parse. This commit adds `InvisibleColumnConstraint`, following the same pattern as `AutoIncrementColumnConstraint` and `ZeroFillColumnConstraint`. The constraint is MySQL-specific and is registered in the MySQL dialect's `CONSTRAINT_PARSERS`. The generator emits the bare `INVISIBLE` keyword via an inline lambda in `TRANSFORMS`. Note that `SHOW CREATE TABLE` emits invisible columns using MySQL's version-comment syntax (`/*!80023 INVISIBLE */`), which the tokenizer treats as a comment. This commit does not address that; it only supports the bare keyword in input DDL.
VaggelisD
approved these changes
Apr 17, 2026
Collaborator
VaggelisD
left a comment
There was a problem hiding this comment.
Thank you for the PR! Had one nit but it's good to go
Merged
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.
MySQL 8.0.23 introduced invisible columns, declared with the
INVISIBLEkeyword in column definitions. Until now, sqlglot could parseALTER TABLE ... ALTER COLUMN ... SET INVISIBLE(PR #4809) andALTER TABLE ... ALTER INDEX ... INVISIBLE(PR #4800), but the keyword was not recognized in column definitions. This meantCREATE TABLE t (c INT INVISIBLE)andALTER TABLE t ADD COLUMN c INT INVISIBLEboth failed to parse.This commit adds
InvisibleColumnConstraint, following the same pattern asAutoIncrementColumnConstraintandZeroFillColumnConstraint. The constraint is MySQL-specific and is registered in the MySQL dialect'sCONSTRAINT_PARSERS. The generator emits the bareINVISIBLEkeyword via an inline lambda inTRANSFORMS.Note that
SHOW CREATE TABLEemits invisible columns using MySQL's version-comment syntax (/*!80023 INVISIBLE */), which the tokenizer treats as a comment. This commit does not address that; it only supports the bare keyword in input DDL.