Commit 18231ca
authored
fix(mysql): parse quoted constraint names. (#7519)
sqlglot's `_parse_unique_key` checks whether the current token matches a
`CONSTRAINT_PARSERS` keyword to decide if it should stop parsing the
index name. The check used `self._curr.text.upper()` without considering
the token type, so backtick-quoted identifiers like `` `Unique` ``, ``
`Index` ``, and `` `Key` `` were mistaken for constraint keywords and
rejected.
MySQL allows any identifier as an index name when it is quoted. The
tokenizer already classifies these as `TokenType.IDENTIFIER`, so the fix
adds a `token_type != TokenType.IDENTIFIER` guard to the existing check.
Quoted names skip the keyword lookup entirely and fall through to
`_parse_id_var` as intended.1 parent 998b42b commit 18231ca
2 files changed
Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7262 | 7262 | | |
7263 | 7263 | | |
7264 | 7264 | | |
7265 | | - | |
| 7265 | + | |
| 7266 | + | |
| 7267 | + | |
| 7268 | + | |
| 7269 | + | |
7266 | 7270 | | |
7267 | 7271 | | |
7268 | 7272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
147 | 159 | | |
148 | 160 | | |
149 | 161 | | |
| |||
0 commit comments