-
Notifications
You must be signed in to change notification settings - Fork 388
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
Escape sql special like characters #1066
Conversation
7a75cfd
to
6869c68
Compare
|
||
def escape_like(string, escape_char='*'): | ||
"""Escape the string parameter used in SQL LIKE expressions.""" | ||
return string.replace(escape_char, escape_char * 2) \ |
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.
So a *
becomes **
? How does this affect the query?
If I have csordas*marton
as filter and I have csordas*marton
and csordasFOOBARmarton
as run names in the database I get only the first as result?
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.
If you have two run names (csordas*marton
and csordasFOOBARmarton
) you get only the first as result for csordas*marton
filter.
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.
This escaping applies to the run and product names when the user starts typing an infix of these for filtering. I think it is not necessary to accept joker characters in this situation, so it wouldn't be a problem if asterisk is interpreted as an exact character.
"There should be one run for this test.") | ||
|
||
# Filter runs which name contains `test_files*`. | ||
test_runs = self.__get_runs('test_files*') |
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.
I think there could be more tests, e.g. for **, %
.
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.
Okay, I've created a few more test cases.
6869c68
to
4e89572
Compare
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.
LG!
Closes #902