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
MySQLi escapeLikeStringDirect() #2229
Conversation
e7eb10c
to
2ef84c6
Compare
Someone tell me how those are valid Postgres strings:
|
Looks like two diferent escaping expectations, one with ' and one with '' ro end up with a single quote inside a single-quoted string Can't attest to their validity, but it looks to me like the search is for "O'Doules" |
Surely that can't be right? How could Postgres escape a character within a string wrapped in |
I have seen that convention before, with other programming languages. I don't know anything about Postgres. |
Yeah me neither! I thought I was adding some easy tests, but I suppose it was foolish to assume the same escape character across all drivers. |
Escaping single quotes https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS |
@michalsn Thanks for elucidating! I'm trying a version using each driver's escape char instead. |
Finally got it! Someone please review - basically:
|
Looks fine to me, but I'm definitely not an expert on it. I'll take yours - and the tests - word for it. |
I'm no expert but I feel a lot closer after 7 commits 😳 Put it on the list for 4.5 when we rewrite the Database layer that escape types should be differentiated better and implementations standardized better. |
Oh, so now the database rewrite is an actual thing :) I definitely think it's showing it's age and the fact that it's been updated and worked on for 10+ years. Part of me would really like to rewrite that at some point, but not looking forward to it either lol |
Oh yes, most definitely! I'm creating a milestone and assigning only you, with a November deadline. Good luck! |
Jokes aside I just looked at my PR history and 11 out of the last 15 were for the database layer, mostly all bug fixes. |
Description
As @michalsn points out, some MySQL commands (e.g. "SHOW ____") don't support custom escape characters supplied via "ESCAPE x". Currently
listTables()
is the only framework function suffering from this limitation, but it causeslistTables()
with$constrainPrefix
to fail to constrain correctly.This PR defines a new platform-specific function
escapeLikeStringDirect()
that can be used for those rare instances when both "SHOW" and "LIKE" are retried in the same query. This new function applies the default escape character\
directly the the "LIKE" string for any wildcards. This also has the MySQLi driver's_listTables()
function use this new method instead to the generic one designed for "SELECT" statements.Refs:
Checklist: