Repository navigation
Commit 57eb90d
authored
Fix odd-length hexadecimal literals (#573)
The AST driver converts `0x711` to `x'711'`, which SQLite rejects. This
breaks otherwise valid queries and SQL imports.
**Pad odd-length `0x` literals with a leading zero** before translating
them to SQLite blob literals, matching [MySQL's documented
behavior](https://dev.mysql.com/doc/refman/8.4/en/hexadecimal-literals.html).
Existing leading zeros are preserved, and odd-length quoted `X'…'`
literals remain invalid.
Regression tests cover reads, `HEX()`, inserts and updates into text and
blob columns, single-digit values, leading zeros, mixed-case digits,
long literals, and invalid quoted literals.
Fixes #543.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Odd-length numeric hexadecimal literals are now handled correctly in
queries and when writing to text, varchar, or blob columns. A leading
zero completes the final byte; for example, `0x711` is interpreted as
`0x0711`. Even-length numeric literals continue to behave as before.
* Odd-length quoted hexadecimal literals remain rejected rather than
being treated as valid numeric literals.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 0a7c269 commit 57eb90d
3 files changed
Lines changed: 90 additions & 8 deletions
File tree
- packages/mysql-on-sqlite
- src/sqlite
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4541 | 4541 | | |
4542 | 4542 | | |
4543 | 4543 | | |
4544 | | - | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
| 4547 | + | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
4545 | 4551 | | |
4546 | 4552 | | |
4547 | 4553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11153 | 11153 | | |
11154 | 11154 | | |
11155 | 11155 | | |
11156 | | - | |
11157 | | - | |
11158 | | - | |
| 11156 | + | |
| 11157 | + | |
| 11158 | + | |
| 11159 | + | |
| 11160 | + | |
| 11161 | + | |
| 11162 | + | |
| 11163 | + | |
| 11164 | + | |
| 11165 | + | |
11159 | 11166 | | |
11160 | | - | |
11161 | | - | |
| 11167 | + | |
| 11168 | + | |
| 11169 | + | |
| 11170 | + | |
| 11171 | + | |
| 11172 | + | |
| 11173 | + | |
| 11174 | + | |
| 11175 | + | |
| 11176 | + | |
| 11177 | + | |
| 11178 | + | |
| 11179 | + | |
| 11180 | + | |
| 11181 | + | |
| 11182 | + | |
| 11183 | + | |
| 11184 | + | |
| 11185 | + | |
11162 | 11186 | | |
11163 | | - | |
11164 | | - | |
| 11187 | + | |
| 11188 | + | |
| 11189 | + | |
| 11190 | + | |
| 11191 | + | |
| 11192 | + | |
| 11193 | + | |
| 11194 | + | |
| 11195 | + | |
| 11196 | + | |
| 11197 | + | |
| 11198 | + | |
| 11199 | + | |
| 11200 | + | |
| 11201 | + | |
| 11202 | + | |
| 11203 | + | |
| 11204 | + | |
| 11205 | + | |
| 11206 | + | |
| 11207 | + | |
| 11208 | + | |
| 11209 | + | |
| 11210 | + | |
| 11211 | + | |
| 11212 | + | |
| 11213 | + | |
| 11214 | + | |
| 11215 | + | |
| 11216 | + | |
| 11217 | + | |
| 11218 | + | |
| 11219 | + | |
| 11220 | + | |
| 11221 | + | |
| 11222 | + | |
| 11223 | + | |
| 11224 | + | |
| 11225 | + | |
| 11226 | + | |
| 11227 | + | |
| 11228 | + | |
| 11229 | + | |
| 11230 | + | |
11165 | 11231 | | |
11166 | 11232 | | |
11167 | 11233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1742 | 1742 | | |
1743 | 1743 | | |
1744 | 1744 | | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
1745 | 1755 | | |
1746 | 1756 | | |
1747 | 1757 | | |
| |||
0 commit comments