-
Notifications
You must be signed in to change notification settings - Fork 45
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
Information schema #25
Conversation
Testing CHAR_LENGTH and SUBSTRING support. Testing LIKE '\_%' (escaped LIKE) support.
Added CHAR_LENGTH and SUBSTRING support as rewrites to LENGTH and SUBSTR. Added LIKE '\_%' (escaped LIKE) support. Corrected GREATEST and LEAST functions, added unit tests.
if ( str_contains( $unescaped_value, '\_') || str_contains( $unescaped_value, '\%') ) { | ||
$this->like_escape_count ++; | ||
return str_replace( | ||
array ( '\_', '\%' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would _
be a wildcard in a string like \\_
? If so, this may require a sub-parser just for the wildcards and backslashes. Lexer already does some of this work, though, to parse the string literals that may look like UPDATE x SET y='\\\'\\\\\\'
– I wonder if that code is somehow reusable here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, a double backslash turns _
into a wildcard again:
sqlite> select 1 WHERE '\\ot' LIKE '\\_%' ESCAPE '\';
1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OllieJones This was marked as resolved but the problem is still there.
Great work on this one @OllieJones! I left some notes but this is the right direction. Do core unit tests still pass? |
By "core" unit tests I guess you mean the ones with this plugin. They do indeed pass. I've added features and unit tests based on stuff I found in some data-maint plugins. Thanks for your review; I'll incorporate your changes when I get a chance. |
Oh I meant WordPress core with this plugin installed. I've got almost all of them to pass in #9 and it would be great to avoid regressions:
The remaining failures can be mostly ignored as they're tests calling private wpdb mysql-related functions. |
I think we can merge this one as-is and continue iterating in follow-up PR. |
@aristath I'd still love to understand how it impacts WordPress core unit tests. What would it take to automate that with a CI check? Also, I feels strongly about not counting |
Fixes from your reviews now pushed. It's ready to merge, I think. |
Backports changes from WordPress/sqlite-database-integration#25
Merged the PR, then fixed some CS issues in 65c50f4 and backported the changes to WordPress/wordpress-develop#3220 as well 👍 |
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
Backports changes from WordPress/sqlite-database-integration#25
#19 #20 #21 #22
Escaping LIKE literal % and _.
More information_schema and metadata compatiblity.
Unique constraint violations, and other errors when running queries, now detected and reported.
SUBSTRING and CHAR_LENGTH now handled by rewriting the query to SUBSTR and LENGTH.