Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

Add SQLite compatibility to wp db commands

This PR implements SQLite support for database commands when using the SQLite Database Integration plugin. Commands now detect SQLite via DB_ENGINE constant, SQLITE_DB_DROPIN_VERSION, or db.php drop-in inspection.

Changes

  • New DB_Command_SQLite trait - Isolated SQLite operations using PDO:

    • create/drop/reset - File-based database lifecycle
    • query - Direct PDO execution with formatted output (now supports --skip-column-names)
    • export/import - SQL dump/restore with proper identifier escaping
    • size - File size calculation
    • Database path resolution supporting FQDB, FQDBDIR, DB_FILE constants
  • Modified DB_Command methods - Detect SQLite and route accordingly:

    • create, drop, reset, query, export, import - Full SQLite implementation
    • size - SQLite file size vs MySQL information_schema query
    • check, optimize, repair, cli - Warning messages (not applicable to SQLite)
    • tables, prefix, columns, search, clean - Unchanged (work via $wpdb)
  • Test scenarios - Updated to support SQLite for --skip-column-names flag

  • Documentation (README.md) - Supported commands, configuration, detection methods

Recent Updates

  • Added --skip-column-names support for SQLite: The sqlite_query() method now accepts $assoc_args and respects the --skip-column-names flag
  • Replaced custom display_table() with Formatter class: Using the standard WP-CLI Formatter class for consistency with other commands
  • Updated tests: Removed MySQL-only restriction from --skip-column-names test as SQLite now supports it

Example Usage

# Works automatically when SQLite is detected
wp db query "SELECT * FROM wp_posts"
wp db query "SELECT * FROM wp_posts" --skip-column-names
wp db export backup.sql
wp db size

Technical Notes

  • PDO used for direct operations, enabling functionality at after_wp_config_load stage
  • SQLite identifiers escaped with double-quotes, values via PDO::quote()
  • Default database path: wp-content/database/.ht.sqlite
  • Full backward compatibility - MySQL/MariaDB code paths unchanged
  • Uses WP-CLI Formatter class for query output formatting

Fixes #234


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits November 20, 2025 16:30
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add SQLite compatibility to wp db commands Add SQLite compatibility to wp db commands Nov 20, 2025
Copilot AI requested a review from swissspidy November 20, 2025 16:41
@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

❌ Patch coverage is 14.84848% with 281 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/DB_Command_SQLite.php 4.01% 239 Missing ⚠️
src/DB_Command.php 48.14% 42 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy

This comment was marked as resolved.

Copilot AI and others added 2 commits February 8, 2026 22:00
… class

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add SQLite compatibility to wp db commands

2 participants