Skip to content

ANY Column Type Gets Wrong Affinity in Non-STRICT Tables #5431

@LeMikaelF

Description

@LeMikaelF

Description

In non-STRICT tables, a column declared with type ANY gets BLOB affinity instead of NUMERIC affinity. This causes text values like '42' to be stored as TEXT instead of being coerced to integer.

Reproducer

CREATE TABLE t ( c ANY );
INSERT INTO t VALUES ('42');
SELECT typeof(c) FROM t;
-- Turso: text
-- SQLite: integer

Per SQLite documentation, the affinity determination rules are applied sequentially: (1) contains "INT" → INTEGER, (2) contains "CHAR"/"CLOB"/"TEXT" → TEXT, (3) contains "BLOB" or no type → BLOB, (4) contains "REAL"/"FLOA"/"DOUB" → REAL, (5) "Otherwise, the affinity is NUMERIC." Since "ANY" matches none of rules 1-4, it should get NUMERIC affinity by rule 5.

core/vdbe/affinity.rs:165 - Incorrect mapping of ANY type to BLOB affinity instead of NUMERIC.


This issue brought to you by Mikaël and Claude Code.

Metadata

Metadata

Assignees

Labels

affinitycorrectnessgood first issueGood for newcomerssqlrightbugs found using SQLRight (https://github.com/PSU-Security-Universe/sqlright)Ï

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions