WordPress / WordPress/sqlite-database-integration
Emulate UNSIGNED integer semantics for CAST and CONVERT
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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