Skip to content

Emulate UNSIGNED integer semantics for CAST and CONVERT #359

@JanJakes

Description

@JanJakes

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions