Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stuartlangridge
Copy link

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.

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.
stuartlangridge added a commit to stuartlangridge/search-replace-command that referenced this pull request Feb 14, 2023
When using wp-sqlite-db as the back end for WordPress, wpcli's `search-replace` command fails because wp-sqlite-db returns text column types as `TEXT`, and wpcli search-replace checks whether a column is textual in `is_text_col` with `strpos` for "text" or "varchar". If this were `stripos` instead of `strpos` then this problem would be resolved, which would be nice, and I don't believe there would be any backward compatibility implications. So, here's a one-character PR :-)

(Of course, sqlite as backend isn't actually supported, but this is a fairly small change which should make things better for that without affecting the mainline code. I've also proposed aaemnnosttv/wp-sqlite-db#56 to wp-sqlite-db to have that return lowercase "text" for column types as well, thus hopefully fixing the problem at both ends.)
danielbachhuber pushed a commit to wp-cli/search-replace-command that referenced this pull request Feb 15, 2023
When using wp-sqlite-db as the back end for WordPress, wpcli's `search-replace` command fails because wp-sqlite-db returns text column types as `TEXT`, and wpcli search-replace checks whether a column is textual in `is_text_col` with `strpos` for "text" or "varchar". If this were `stripos` instead of `strpos` then this problem would be resolved, which would be nice, and I don't believe there would be any backward compatibility implications. So, here's a one-character PR :-)

(Of course, sqlite as backend isn't actually supported, but this is a fairly small change which should make things better for that without affecting the mainline code. I've also proposed aaemnnosttv/wp-sqlite-db#56 to wp-sqlite-db to have that return lowercase "text" for column types as well, thus hopefully fixing the problem at both ends.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant