Commit b8fd9d0
committed
Don't crash on malformed SQL that makes sqlglot raise mid-parse
DialectParser runs sqlglot in WARN mode so it returns a best-effort AST instead
of raising. For a handful of short inputs like "{ =" sqlglot instead raises an
AttributeError while assembling that partial tree (a node whose key is None).
That was neither ParseError nor TokenError, so it escaped _try_dialects and
every public accessor (tables, columns, query_type, ...) crashed with a raw
AttributeError.
Catch any such sqlglot-side failure in _parse_with_dialect and treat it as 'this
dialect produced no result', so the query is reported through the normal
InvalidQueryDefinition path. ParseError/TokenError are still re-raised so the
existing syntax-error handling is unchanged.1 parent 65c18c1 commit b8fd9d0
2 files changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
252 | 264 | | |
253 | 265 | | |
254 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
0 commit comments