You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MySQL: Allow optional constraint name after CONSTRAINT keyword
MySQL allows `CONSTRAINT CHECK (expr)` without a name - the database will
auto-generate a constraint name. This is a MySQL extension; the SQL standard
requires a name after the CONSTRAINT keyword. See [docs].
Previously, we required an identifier after CONSTRAINT, causing us to
interpret CONSTRAINT as a column name in cases like:
```sql
CREATE TABLE t (x INT, CONSTRAINT CHECK (x > 1))
```
Now we check if the token after CONSTRAINT is a constraint type keyword
(CHECK, PRIMARY, UNIQUE, FOREIGN) and treat the name as optional for
dialects that support this. This is just MySQL as far as I know (and
Generic), but we introduce a new `Dialect` flag even though it's a minor
feature. We could remove the flag and allow the more permissive optional
name syntax across dialects if desired.
[docs]: https://dev.mysql.com/doc/refman/8.4/en/create-table.html
0 commit comments