You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The AST driver converts 0x711 to x'711', which SQLite rejects. This breaks otherwise valid queries and SQL imports.
Pad odd-length 0x literals with a leading zero before translating them to SQLite blob literals, matching MySQL's documented behavior. Existing leading zeros are preserved, and odd-length quoted X'…' literals remain invalid.
Regression tests cover reads, HEX(), inserts and updates into text and blob columns, single-digit values, leading zeros, mixed-case digits, long literals, and invalid quoted literals.
Odd-length numeric hexadecimal literals are now handled correctly in queries and when writing to text, varchar, or blob columns. A leading zero completes the final byte; for example, 0x711 is interpreted as 0x0711. Even-length numeric literals continue to behave as before.
Odd-length quoted hexadecimal literals remain rejected rather than being treated as valid numeric literals.
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.
Walkthrough
The translator now pads odd-length numeric 0x literals with a leading zero before emitting SQLite hex-string literals. Tests cover conversion, decoded values, writes to text and blob columns, and rejection of odd-length quoted hexadecimal literals.
Changes: Hexadecimal literal handling
Layer / File(s)
Summary
Pad odd-length numeric literals packages/mysql-on-sqlite/src/sqlite/class-wp-mysql-on-sqlite.php, packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Tests.php, packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Translation_Tests.php
translate_token() pads odd-length numeric hexadecimal payloads before emitting SQLite hex-string literals. Tests cover odd- and even-length forms, decoded bytes, writes to text and blob columns, and rejection of odd-length quoted forms.
Odd-length numeric hex literals are padded without changing quoted literals. No merge-blocking risk is identified.
Pre-merge checks: 4 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: fixing odd-length hexadecimal literal handling.
Linked Issues check
Issue #543 requires that odd-length unquoted 0x literals be left-padded to whole bytes before SQLite translation, so 0x711 becomes x'0711'. Odd-length quoted X'…' literals must stay invalid. The whole…
Out of Scope Changes check
The reported changes are limited to hexadecimal-literal translation in class-wp-mysql-on-sqlite.php and regression tests in WP_MySQL_On_SQLite_Tests.php and WP_MySQL_On_SQLite_Translation_Tests.php. T…
Full details: Linked Issues check
Explanation
Issue #543 requires that odd-length unquoted 0x literals be left-padded to whole bytes before SQLite translation, so 0x711 becomes x'0711'. Odd-length quoted X'…' literals must stay invalid. The whole-PR summary states that translate_token() in packages/mysql-on-sqlite/src/sqlite/class-wp-mysql-on-sqlite.php prepends a zero to odd-length HEX_NUMBER payloads and leaves even-length payloads unchanged (+7/-1). The test summaries cover 0x711 → x'0711' and 0x00711 → x'000711' in WP_MySQL_On_SQLite_Translation_Tests.php, read and write tests for text and blob columns in WP_MySQL_On_SQLite_Tests.php, and rejection of odd-length quoted literals through testOddLengthQuotedHexadecimalLiteralsAreRejected. The prior review read the source directly and found the same behavior. In this review, the source diff tool could not read the changed blobs, and the file read was truncated before the HEX_NUMBER section. The source-level conclusion therefore rests on the summaries and the prior review, not on a fresh line-level read. The change since the previous reviewed head (1313683) was not separately verified.
Full details: Out of Scope Changes check
Explanation
The reported changes are limited to hexadecimal-literal translation in class-wp-mysql-on-sqlite.php and regression tests in WP_MySQL_On_SQLite_Tests.php and WP_MySQL_On_SQLite_Translation_Tests.php. The production change is the padding of odd-length 0x payloads, which implements #543. The test changes verify that padding, its write-path behavior, and the quoted-literal rejection that #543 requires. The test method signature change to testHexadecimalLiterals(string $literal, string $hex) and the new data providers support those same cases. The summaries identify no unrelated production behavior or unrelated test area. The source diff could not be read directly in this review, so this conclusion relies on the summaries and the prior review.
Full details: Docstring Coverage
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files. (1 skipped: 1 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
PHPStan (2.3.0)
PHPStan reported 1 non-file analysis error(s); analysis is incomplete
PHPMD could not process this file (exit code 255): 0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0%
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2097152 bytes) in phar:///usr/bin/phpmd/vendor/pdepend/pdepend/src/Util/Cache/Driver/FileCacheDriver.php on line 183
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Add a leading zero to odd-length 0x literals before translating them to SQLite blob literals. Preserve leading zeros and keep rejecting odd-length quoted hexadecimal literals.
Cover SELECT, HEX(), INSERT, UPDATE, and literal edge cases.
Fixes#543
## Release `3.1.2`
Version bump and changelog update for release `3.1.2`.
**Changelog draft:**
* Allow configuring the SQLite busy timeout with `SQLITE_BUSY_TIMEOUT`
([#558](#558))
* Keep the user transaction active after a failed statement
([#536](#536))
* Support odd-length `0x` hexadecimal literals
([#573](#573))
* Fix rebuilds of legacy text and binary columns
([#565](#565))
* Use `'0'` column defaults in non-strict `INSERT` statements
([#569](#569))
* Roll back failed `OPTIMIZE TABLE` and `REPAIR TABLE` rebuilds
([#567](#567))
* Remove the Rust parser extension
([#566](#566))
* Preserve `AUTO_INCREMENT` counters when rebuilding tables
([#561](#561))
* Fix `ALTER TABLE ... ADD (...)` for columns, indexes, and constraints
([#557](#557))
* Fix `ON UPDATE CURRENT_TIMESTAMP` for explicit values and unchanged
rows
([#560](#560))
* Normalize zero defaults in date and time columns
([#542](#542))
* Add support for `ALTER COLUMN` with `SET DEFAULT` and `DROP DEFAULT`
([#555](#555))
**Full changelog:**
v3.1.1...release/v3.1.2
## Next steps
1. **Review** the changes in this pull request.
2. **Push** any additional edits to this branch (`release/v3.1.2`).
3. **Merge** this pull request to complete the release.
Merging will automatically build the plugin ZIP, create a [GitHub
release](https://github.com/WordPress/sqlite-database-integration/releases),
and deploy to
[WordPress.org](https://wordpress.org/plugins/sqlite-database-integration/).
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Release**
* Updated the SQLite database integration to version 3.1.2.
* **New Features**
* Added support for more `ALTER TABLE` operations and configurable
SQLite busy timeouts.
* **Bug Fixes**
* Improved transaction handling after failed statements and addressed
SQL compatibility, table rebuild, and default-value handling issues.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The AST driver converts
0x711tox'711', which SQLite rejects. This breaks otherwise valid queries and SQL imports.Pad odd-length
0xliterals with a leading zero before translating them to SQLite blob literals, matching MySQL's documented behavior. Existing leading zeros are preserved, and odd-length quotedX'…'literals remain invalid.Regression tests cover reads,
HEX(), inserts and updates into text and blob columns, single-digit values, leading zeros, mixed-case digits, long literals, and invalid quoted literals.Fixes #543.
Summary by CodeRabbit
0x711is interpreted as0x0711. Even-length numeric literals continue to behave as before.