Skip to content

Adapt SQLite support to sqlite-database-integration 3.0 - #344

Merged
swissspidy merged 2 commits into
mainfrom
claude/db-command-failing-tests-shykpc
Aug 14, 2026
Merged

Adapt SQLite support to sqlite-database-integration 3.0#344
swissspidy merged 2 commits into
mainfrom
claude/db-command-failing-tests-shykpc

Conversation

@swissspidy

@swissspidy swissspidy commented Aug 14, 2026

Copy link
Copy Markdown
Member

Every SQLite job in the matrix has been failing since sqlite-database-integration 3.0 replaced the old translation layer with the MySQL-on-SQLite driver. The MySQL/MariaDB jobs are unaffected. Example run: https://github.com/wp-cli/db-command/actions/runs/31762124942

Three driver behaviors changed. Each was verified by driving the 3.0 driver directly against an in-memory SQLite database rather than inferred from the CI output.

SHOW TABLES is now sorted and honors WHERE

The translation ends in ORDER BY table_name, and the WHERE ... IN (...) clause that Utils\wp_get_table_names() builds is now applied. wp db tables therefore returns the same alphabetically sorted list on SQLite as it does on MySQL.

The @require-sqlite variants of the two db tables scenarios differed from their MySQL counterparts only in that ordering, so this drops the duplicates and lets the original scenarios cover both database types.

Note that the array_intersect() SQLite workaround in wp-cli's wp_get_table_names() is now a no-op, but it still does real work against the 2.x drop-in, so it is best left alone until 3.0 is a hard requirement. No framework change is needed here.

SHOW COLUMNS reports MySQL types and the Extra field

Types come back as date/text rather than the underlying SQLite storage types, and an absent default is NULL rather than a quoted empty string. This was verified to hold under the default SQL mode, wpdb's filtered mode, and an empty mode, so it does not depend on sql_mode.

The driver also returns the Extra field now. columns() dropped it on SQLite because the old drop-in did not provide it; that workaround now hides information that is available, notably auto_increment, so it is removed. With Extra restored the SQLite db columns scenario expects exactly what the MySQL one does, so that duplicate goes too.

Multi-queries are rejected

wp db query "CREATE TABLE ... );;" fails with Multi-query is not supported. — the stray second semicolon parses as an empty second statement. The MySQL client silently ignores it, which is why that line sat unnoticed in db-columns.feature.

Rather than edit the test, this trims redundant trailing semicolons in the SQLite query path so wp db query behaves the same on both backends. The ;; stays in the feature file as regression coverage.

Not addressed here

wp db export includes the driver's internal _wp_sqlite_* tables in the dump. That looks like something to strip, but excluding them is worse: a round-trip through a stripped dump reconstructs the schema lossily, turning bigint(20) unsigned into int, datetime into varchar(65535), longtext into text, and NOT NULL columns into nullable ones. On tables with an auto-increment column, every column additionally comes back marked auto_increment and all defaults are lost, which looks like a bug worth reporting upstream.

Since wp db export on SQLite emits a sqlite3 .dump whose only real consumer is wp db import into another SQLite install, keeping the information schema is the correct behavior. The existing _mysql_data_types_cache exclusion is dead code under 3.0 and harmless.

One inconsistency does remain: wp db export --tables=... builds its exclusion list as "everything not requested", which sweeps the internal tables out, so targeted exports are lossy while full exports are not. Happy to address that separately if wanted.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Database column listings now consistently include the Extra field for SQLite output.
    • SQLite queries now handle trailing semicolons and whitespace correctly.
    • Empty SQLite queries now return a clear “No query specified.” error.
  • Tests

    • Updated database scenario coverage to reflect consistent behavior across supported database types and WordPress versions.

claude added 2 commits August 14, 2026 08:23
The 3.0 release of the SQLite drop-in replaced the old translation layer
with the MySQL-on-SQLite driver, which changes three things the Behat
suite relied on. All `SQLite` matrix jobs went red as a result, while the
MySQL/MariaDB jobs stayed green.

`SHOW TABLES` now sorts by table name and honors a `WHERE` clause, so
`wp db tables` returns the same alphabetically sorted list it returns on
MySQL. The `@require-sqlite` variants of the two `db tables` scenarios
only differed from their MySQL counterparts in that ordering, so drop the
duplicates and let the original scenarios cover both database types.

`SHOW COLUMNS` now reports MySQL types instead of the underlying SQLite
storage types, and no longer quotes an absent default, so `db columns`
reports `date`/`text` with an empty default rather than `TEXT`/`''`.

Finally, the driver rejects multi-queries, and a query with redundant
trailing semicolons parses as one. The MySQL client silently ignores the
empty statements they produce, so trim them in the SQLite query path to
keep `wp db query` behaving the same on both.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MXbmdB7hvQ2jwEe64h6s5K
`columns()` dropped `Extra` from the output on SQLite because the old
SQLite drop-in did not return that field from `SHOW COLUMNS`. The
MySQL-on-SQLite driver in sqlite-database-integration 3.0 returns the
full MySQL-compatible column set, so the workaround now hides
information that is available, notably `auto_increment`.

With `Extra` restored, the SQLite variant of the `db columns` scenario
expects exactly what the MySQL variant does, so drop the duplicate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MXbmdB7hvQ2jwEe64h6s5K
@swissspidy
swissspidy requested a review from a team as a code owner August 14, 2026 08:53
Copilot AI lite review requested due to automatic review settings August 14, 2026 08:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1393e93a-c481-444a-ac7b-ec5d13ffdff0

📥 Commits

Reviewing files that changed from the base of the PR and between 5f75759 and e2c502e.

📒 Files selected for processing (4)
  • features/db-columns.feature
  • features/db-tables.feature
  • src/DB_Command.php
  • src/DB_Command_SQLite.php
💤 Files with no reviewable changes (2)
  • features/db-columns.feature
  • src/DB_Command.php

📝 Walkthrough

Walkthrough

The database commands now normalize and validate SQLite queries, use consistent column output across database types, and update feature coverage by removing SQLite-specific scenarios and adjusting requirement tags.

Changes

Database command updates

Layer / File(s) Summary
SQLite query validation
src/DB_Command_SQLite.php
sqlite_query() trims trailing semicolons and whitespace, then returns No query specified. for empty queries.
Column output consistency
src/DB_Command.php
The columns() command includes the Extra field for SQLite output.
Database scenario alignment
features/db-columns.feature, features/db-tables.feature
SQLite-specific scenarios were removed. MySQL/MariaDB tags were removed where no longer required, and the multisite scenario now requires WordPress 3.9.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to e2c50

The PR aligns SQLite table, column, and query behavior with the updated driver and removes redundant backend-specific scenarios; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested labels: command:db

Suggested reviewers: brianhenryie, ernilambar, janw-me

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adapting SQLite support for sqlite-database-integration 3.0.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/db-command-failing-tests-shykpc

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added bug command:db-columns Related to 'db columns' command command:db-query Related to 'db query' command command:db-tables Related to 'db tables' command scope:testing Related to testing labels Aug 14, 2026
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/DB_Command_SQLite.php 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Member Author

All 48 Behat jobs are green, including every SQLite job that was failing before this PR.

The one red check is codecov/patch at 0% of diff hit, which is structural rather than a coverage gap in this change. Coverage is collected by exactly one job — Behat | PHP 8.5 | WP latest | mysql-8.0 (with coverage) — and the three added lines live in sqlite_query(), which only executes when the SQLite drop-in is active. A MySQL-only coverage run cannot reach them, so any change to that method would report 0%.

The behavior itself is covered: the trailing-semicolon path is exercised by features/db-columns.feature on the SQLite jobs. Making it measurable would mean collecting coverage from a SQLite job as well, which is configured in wp-cli/.github's reusable-testing.yml rather than in this repository.


Generated by Claude Code

@swissspidy swissspidy added this to the 3.0.1 milestone Aug 14, 2026
@swissspidy
swissspidy merged commit d1f779e into main Aug 14, 2026
56 of 57 checks passed
@swissspidy
swissspidy deleted the claude/db-command-failing-tests-shykpc branch August 14, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:db-columns Related to 'db columns' command command:db-query Related to 'db query' command command:db-tables Related to 'db tables' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants