Commit 6678ee0
feat(mysql): Add
* Add `INVISIBLE` column constraint for MySQL.
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 #4809) and `ALTER TABLE
... ALTER INDEX ... INVISIBLE` (PR #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.
* Update tests/dialects/test_mysql.py
---------
Co-authored-by: Vaggelis Danias <daniasevangelos@gmail.com>INVISIBLE column constraint for MySQL. (#7510)1 parent 379c63e commit 6678ee0
4 files changed
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| 237 | + | |
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
250 | 251 | | |
251 | 252 | | |
252 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
1680 | 1682 | | |
1681 | 1683 | | |
1682 | 1684 | | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
0 commit comments