Commit ba6b01b
committed
Flatten YEAR cast nested subquery for Turso
The YEAR cast in cast_value_for_saving wraps the integer-cast value
in a derived table to alias it as `value` so the CASE branches can
reference it once:
(SELECT CASE WHEN value IS NULL THEN NULL ... END
FROM (SELECT CAST(<column-ref> AS INTEGER) AS value))
In an INSERT-SELECT-FROM-VALUES context the <column-ref> resolves
two levels up — past the inner SELECT and past the outer per-column
projection — and Turso fails the binding with
"Parse error: no such column: columnN", breaking six tests that
exercise YEAR via INSERT...VALUES:
testNonStrictModeTypeCasting (column17)
testColumnInfoForDateAndTimeDataTypes (column5)
testCastValuesOnInsert (column1)
testCastValuesOnInsertInNonStrictMode (column1)
testCastValuesOnUpdate (column1)
testCastValuesOnUpdateInNonStrictMode (column1)
A direct CI probe of one-level FROM-VALUES references (with and
without CAST/backticks/INSERT context) showed every shape passes
on Turso. The failure is specific to the YEAR cast's *nested*
derived FROM. Other date/time types use a flat CASE and work.
Flatten the YEAR cast to inline `CAST(... AS INTEGER)` at every
WHEN — CAST is idempotent so the rewrite is semantically identical.
All 667 mysql-on-sqlite tests pass with the patch on real SQLite.1 parent ce22919 commit ba6b01b
1 file changed
Lines changed: 71 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1662 | 1662 | | |
1663 | 1663 | | |
1664 | 1664 | | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
1665 | 1736 | | |
1666 | 1737 | | |
1667 | 1738 | | |
| |||
0 commit comments