#32411: Case-insensitive lookups on JSONField doesn't work on MySQL.
-------------------------------------+-------------------------------------
     Reporter:  elonzh               |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  JSONField mysql      |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * status:  closed => new
 * cc: sage (added)
 * type:  Bug => Cleanup/optimization
 * keywords:  JSONField => JSONField mysql
 * resolution:  invalid =>
 * stage:  Unreviewed => Accepted


Comment:

 This is not a documented usage, however it doesn't work only on MySQL, so
 IMO we can fix this for consistency. MySQL handles strings used in `JSON`
 context using the `utf8mb4_bin`  binary collation, that's why comparison
 of JSON values is case-sensitive and we need to use
 `CaseInsensitiveMixin`. We can fix this be registering a custom case-
 insensitive lookup for `JSONField`, e.g.
 {{{
 class JSONFieldIContains(CaseInsensitiveMixin, lookups.IContains):
     pass


 JSONField.register_lookup(JSONFieldIContains)
 }}}
 I don't think it makes sense to do the same for `__istartswith`,
 `iendswith`, and `__iexact`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32411#comment:3>
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 on the web visit 
https://groups.google.com/d/msgid/django-updates/064.10a9d8f62c2fdf73ff158051e67b8be2%40djangoproject.com.

Reply via email to