Fix transform() corrupting ANY columns on STRICT tables to REAL

column_affinity() fell through all type checks for the SQLite-specific
ANY column type and returned float, which then mapped to REAL in
COLUMN_TYPE_MAPPING. This caused transform() on a STRICT table with
ANY columns to either crash with IntegrityError (when existing rows
held non-numeric values) or silently change the column type from ANY
to REAL.

Add ANY as an explicit case in column_affinity() so it passes through
as the string "ANY", and register "ANY"/"any" in COLUMN_TYPE_MAPPING
so create_table_sql() emits the correct column type.

Fixes #790
This commit is contained in:
ikatyal21 2026-07-31 15:58:59 +00:00
commit 7c182f5afa
No known key found for this signature in database
3 changed files with 26 additions and 0 deletions

View file

@ -177,6 +177,8 @@ def column_affinity(column_type: str) -> type:
return bytes
if "REAL" in column_type or "FLOA" in column_type or "DOUB" in column_type:
return float
if column_type == "ANY":
return "ANY" # type: ignore[return-value]
# Default is 'NUMERIC', which we currently also treat as float
return float