aaemnnosttv / wp-sqlite-db

A single file drop-in for using a SQLite database with WordPress. Based on the original SQLite Integration plugin.
561 stars 94 forks source link

Column names from DESCRIBE table to lowercase to match MySQL #56

Open stuartlangridge opened 1 year ago

stuartlangridge commented 1 year ago

wp-cli's search-replace command fails when used against a WordPress installation using wp-sqlite-db, because it looks for text columns in tables by checking the output of DESCRIBE tablename for column types with text or varchar in them, case-sensitively. (See https://github.com/wp-cli/search-replace-command/blob/main/src/Search_Replace_Command.php#L714 for the details; they use strpos to check.)

SQLite (and wp-sqlite-db) returns column type as TEXT, which does not match. This means that search-replace fails because it doesn't detect any text columns in tables.

It would be nice if they used stripos (and I will file a PR over there as well), but making the wp-sqlite-db code convert the returned column type to lowercase fixes this problem, and makes it match MySQL's response more accurately, which seems like a good thing all round.