WordPress / WordPress/sqlite-database-integration

Emulate UNSIGNED integer semantics for CAST and CONVERT

Open
#359 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
363
Forks
67
Avg merge
2d 15h
Merged PRs (30d)
7

Description

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

  • TODOs added in #356.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the TODOs added in #356 and the SQLite driver's handling of CAST(expr AS UNSIGNED) and CONVERT(expr, UNSIGNED). Reproduce the negative-value example, then verify that each supported context matches MySQL's 2^64 modular result and that any additional contexts are explicitly addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sqlite
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.