#36571: Deprecated usage of BINARY expr in MySQL lookups -------------------------------------+------------------------------------- Reporter: Simon Charette | Owner: (none) Type: | Status: new Cleanup/optimization | Component: Database layer | Version: 5.2 (models, ORM) | Severity: Normal | Resolution: Keywords: mysql binary like | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Comment (by Simon Charette):
> Would `CAST(... AS BINARY)` be enough here? This only casts the pattern and not the column? I think you're right, we'd need to cast both the left and right hand side of the operator. > That might lead to subtle differences depending on the column's collation or affect index usage. Would `COLLATE ..._bin` be closer to the old `LIKE BINARY`, since it applies a binary collation to the column and the pattern? The problem with that is that it requires knowing the right-hand-side's collation at query execution time and append the `..._bin` suffix to it. I guess we could use `rhs.output_field.db_collation` and default to `utf8mb_bin` if missing but that could also subtly break as there could be databases out there with collations that are not matching the Django model representation of it and were working fine previously when using `LIKE BINARY`. This whole thing makes me wonder why they deprecated this option in the first place as it seems quite handy. -- Ticket URL: <https://code.djangoproject.com/ticket/36571#comment:2> 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 django-updates+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/django-updates/01070198e40a5660-9cb36ed1-5fba-46be-a7d3-89d15051983a-000000%40eu-central-1.amazonses.com.