#36571: Deprecated usage of BINARY expr in MySQL lookups
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Jason
Type: | Hall
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mysql binary like | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jason Hall):
{{{
escaped_rhs = (
"REPLACE("
" REPLACE("
" REPLACE({rhs}, CHAR(92), CONCAT(CHAR(92),
CHAR(92))),"
" CHAR(37), CONCAT(CHAR(92), CHAR(37))"
" ),"
" CHAR(95), CONCAT(CHAR(92), CHAR(95))"
")"
).format(rhs=rhs)
}}}
I was seing failures in
`expressions.tests.ExpressionsTests.test_patterns_escape` and
`test_insensitive_patterns_escape` because `%`, `_`, and `\` were not
being escaped correctly when the RHS of a pattern lookup was an expression
(e.g. `F("lastname")` ).
Using `'\\\\'` and `'%%%%'` produced incorrect escaping once Django
interpolated the SQL string. I switched to the above code using `CHAR()`
and all the relevant tests seem to be passing when using MySQL.
--
Ticket URL: <https://code.djangoproject.com/ticket/36571#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070198e7929d81-a8cb36e2-19fb-40f0-ba1d-a58152399978-000000%40eu-central-1.amazonses.com.