Problem
MySQL's CAST(expr AS UNSIGNED) and CONVERT(expr, UNSIGNED) wrap negative values using modular arithmetic (2^64). For example, CAST('-10' AS UNSIGNED) returns 18446744073709551606 in MySQL.
SQLite has no unsigned integer type — its integers are always 64-bit signed. Currently, CAST('-10' AS UNSIGNED) returns -10 in the SQLite driver, which is incorrect.
Scope
The UNSIGNED semantics may need to be emulated in multiple places:
CAST(expr AS UNSIGNED) expressions.
CONVERT(expr, UNSIGNED) expressions.
- Potentially other contexts where UNSIGNED integer behavior is expected (e.g., column types, arithmetic).
References
Problem
MySQL's
CAST(expr AS UNSIGNED)andCONVERT(expr, UNSIGNED)wrap negative values using modular arithmetic (2^64). For example,CAST('-10' AS UNSIGNED)returns18446744073709551606in MySQL.SQLite has no unsigned integer type — its integers are always 64-bit signed. Currently,
CAST('-10' AS UNSIGNED)returns-10in the SQLite driver, which is incorrect.Scope
The UNSIGNED semantics may need to be emulated in multiple places:
CAST(expr AS UNSIGNED)expressions.CONVERT(expr, UNSIGNED)expressions.References