Commit 7854295
committed
Fix SELECT item alias for wrapped text literals
The alias-inference logic in translate_select_item() treated any item
whose translation matched the inner text literal's translation as a bare
literal and used the literal value as the alias. This misfired for the
CONVERT(expr USING charset) form, where the translator peels the wrapper
and returns the inner literal unchanged — e.g.
"SELECT CONVERT('Customer' USING utf8mb4)" produced alias "Customer"
instead of the original expression text.
Replace the string-equality heuristic with a structural walk: descend
the AST until we reach a textLiteral, bailing out at any level that
doesn't have exactly one child node. Operator expressions, CAST,
CONVERT, BINARY, unary minus, and function calls all introduce a second
child at some level and are correctly rejected.1 parent 145dcd5 commit 7854295
2 files changed
Lines changed: 15 additions & 6 deletions
File tree
- packages/mysql-on-sqlite
- src/sqlite
- tests
Lines changed: 13 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4696 | 4696 | | |
4697 | 4697 | | |
4698 | 4698 | | |
| 4699 | + | |
| 4700 | + | |
| 4701 | + | |
4699 | 4702 | | |
4700 | | - | |
4701 | | - | |
4702 | | - | |
4703 | | - | |
| 4703 | + | |
| 4704 | + | |
| 4705 | + | |
| 4706 | + | |
| 4707 | + | |
| 4708 | + | |
| 4709 | + | |
| 4710 | + | |
| 4711 | + | |
| 4712 | + | |
4704 | 4713 | | |
4705 | 4714 | | |
4706 | 4715 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
0 commit comments