| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
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>
Codecov Report❌ Patch coverage is 14.76923% with 277 lines in your changes missing coverage. Please review.
📢 Thoughts on this report? Let us know! |
Sorry, something went wrong.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
The command_parts array was being passed directly to \WP_CLI\Process::create() which requires a string command. This caused proc_open() to fail with "expects parameter 1 to be string, array given". Also fixes the .read argument: sqlite3 expects ".read FILENAME" as a single quoted argument, not as two separate arguments. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
sqlite3 .dump produces 'CREATE TABLE' without 'IF NOT EXISTS', so importing the dump back into the same database fails with "table X already exists" and exit code 1. Add a regex replacement to insert 'IF NOT EXISTS' into CREATE TABLE statements from the dump, consistent with the existing handling for CREATE INDEX statements. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
sqlite3 .dump also outputs CREATE TRIGGER and CREATE VIEW statements without IF NOT EXISTS, causing re-import to fail with "already exists". Extend the transformations to add IF NOT EXISTS to all CREATE statements (TABLE, TRIGGER, VIEW, INDEX, UNIQUE INDEX) using regex, so that re-importing a dump into the same database succeeds. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
|
Hi @swissspidy! I was following wp-cli/search-replace-command#190, and seeing it was recently closed, I discovered this pull request. I only want to make sure that what is routed via $wpdb vs. what is re-implemented makes sense. My main worry is that bypassing the SQLite driver can lead to data inconsistency and corruption, as the driver maintains information schema and applies MySQL-specific modifications. Looking at the command list:
For commands like cli, we could use a MySQL proxy that exposes the SQLite database via the MySQL binary protocol, but it would add some complexity. All that said, this mostly applies to the new driver, which is not yet the default in the plugin itself and is only activated with the WP_SQLITE_AST_DRIVER constant. In 3.0.0-rc.1, the legacy driver is fully removed. So I'm thinking, maybe it will make sense to address some of these concerns for >= 3.0? Another question is where should we keep the SQLite-specific logic. Does it make any sense to ship it with the SQLite plugin? Or do you think it's better to keep the support here, especially considering the fact that more and more statements will work natively via $wpdb? If anything is missing on the SQLite driver side, we can implement it for 3.0. I think it should be possible to implement commands like CREATE DATABASE and DROP DATABASE. For the size command, I think it's also possible to have the information schema queries return sizes. I can look into that. Finally, when we know the best path forward, I'm happy to help with these efforts. |
Sorry, something went wrong.
|
Thanks for the ping!
This one already use $wpdb if SQLite is detected, or am I missing something?
Sounds good to me 👍 Is there any rough ETA for 3.0?
Probably have to decide on a case-by-case basis. Generally I'm favorable of relying on the plugin to handle as much as possible (where you see fit of course) to reduce maintenance on our side, especially since it applies to other commands such as search-replace-command as well. Waiting for 3.0 to ship would be convenient for us, as otherwise there's gonna be confusion for users on the latest WP-CLI version but an older SQLite plugin version. In any case, I'm supportive of improving SQLite support across all WP-CLI commands. Feel free to open specific issues or even PRs for anything in need of fixing. |
Sorry, something went wrong.
|
May I ask why there's both wp db support for sqlite and also wp sqlitefrom https://github.com/Automattic/wp-cli-sqlite-command? Seems like these efforts should be consolidated somewhere... |
Sorry, something went wrong.
|
Yeah that extra command doesn't really make sense nowadays :) They can just adopt this one here. |
Sorry, something went wrong.
@swissspidy Ah, the PR description says:
But from the code, it appears that it goes via $wpdb indeed, so this one is good ✅
Hopefully within the next couple of weeks. I'm already tagging RCs, but at the same time, no promises; priorities are always evolving 😆
@nickchomey There is currently a significant difference in that wp db export exports a native SQLite dump, while wp sqlite export exports a MySQL-compatible .sql dump. Same for import. The naming looks a bit upside down. I’d like these to converge so that wp db export has the same semantics for both SQLite and MySQL, and any SQLite-native functionality would be an extra argument or command. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
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:
Modified DB_Command methods - Detect SQLite and route accordingly:
Test scenarios - Updated to support SQLite for --skip-column-names flag
Documentation (README.md) - Supported commands, configuration, detection methods
Security Updates
Recent Updates
Example Usage
Technical Notes
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.