-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Contains does not work as expected with % and _ #2224
Comments
What database are you using? |
Ι've tested it on sqlite and mysql |
This is working fine for me on both Sqlite and Postgresql:
|
For MySQL, simply use a backslash to escape the wildcard characters: .where(User.username.contains('\\%')) |
Strange, I run the following:
I use peewee-3.13.3 and sqlite 3.32.3. The generated SQL query is not equivalent to what I expect. The correct query should be something like the following
|
I must be insane. I think I put in a tiny code-change and had loaded that into memory when I generated that output, because now I'm replicating your output. I will fix this for the common case, thanks for reporting. |
Consider a table with the following values:
When I use the contains method with "%" as an argument, I expect to return foo% and foo%bar, but peewee returns all the columns of the table.
Example query:
I expected that
contains
abstracts the semantics of SQL and properly handles the special characters.The text was updated successfully, but these errors were encountered: