Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sqlglot/dialects/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ class Parser(parser.Parser):
"INDEX": lambda self: self._parse_index_constraint(),
"KEY": lambda self: self._parse_index_constraint(),
"SPATIAL": lambda self: self._parse_index_constraint(kind="SPATIAL"),
"ZEROFILL": lambda self: self.expression(exp.ZeroFillColumnConstraint),
}

ALTER_PARSERS = {
Expand Down
4 changes: 4 additions & 0 deletions sqlglot/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,10 @@ class AutoIncrementColumnConstraint(ColumnConstraintKind):
pass


class ZeroFillColumnConstraint(ColumnConstraint):
arg_types = {}


class PeriodForSystemTimeConstraint(ColumnConstraintKind):
arg_types = {"this": True, "expression": True}

Expand Down
3 changes: 3 additions & 0 deletions sqlglot/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5434,3 +5434,6 @@ def initcap_sql(self, expression: exp.Initcap) -> str:
delimiters = None

return self.func("INITCAP", expression.this, delimiters)

def zerofillcolumnconstraint_sql(self, expression: exp.ZeroFillColumnConstraint) -> str:
return "ZEROFILL"
1 change: 1 addition & 0 deletions tests/dialects/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_ddl(self):
self.validate_identity("CREATE TABLE foo (a BIGINT, INDEX USING BTREE (b))")
self.validate_identity("CREATE TABLE foo (a BIGINT, FULLTEXT INDEX (b))")
self.validate_identity("CREATE TABLE foo (a BIGINT, SPATIAL INDEX (b))")
self.validate_identity("CREATE TABLE foo (a INT UNSIGNED ZEROFILL)")
self.validate_identity("ALTER TABLE t1 ADD COLUMN x INT, ALGORITHM=INPLACE, LOCK=EXCLUSIVE")
self.validate_identity("ALTER TABLE t ADD INDEX `i` (`c`)")
self.validate_identity("ALTER TABLE t ADD UNIQUE `i` (`c`)")
Expand Down