#36865: Casting on __exact searches over non-text fields in admin misses indexes
-------------------------------------+-------------------------------------
     Reporter:  Mike Lissner         |                    Owner:  Mike
                                     |  Lissner
         Type:  Bug                  |                   Status:  closed
    Component:  contrib.admin        |                  Version:  5.2
     Severity:  Normal               |               Resolution:  fixed
     Keywords:  search_fields cast   |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

 * resolution:   => fixed
 * status:  assigned => closed

Comment:

 In [changeset:"4cecf3039586ea738afafb9a28c946bff42c37c1" 4cecf303]:
 {{{#!CommitTicketReference repository=""
 revision="4cecf3039586ea738afafb9a28c946bff42c37c1"
 Fixed #36865 -- Removed casting from exact lookups in admin searches.

 Instead of casting non-text fields to CharField (which prevents index
 usage), skip exact lookups when the search term fails
 formfield.to_python().

 This preserves index usage for valid searches while gracefully handling
 invalid search terms by simply not including them in the query for that
 field.

 For multi-term searches like 'foo 123' on search_fields=['name',
 'age__exact']:
 - 'foo': invalid for age, so only name lookup is used
 - '123': valid for both, so both lookups are used

 This entails a slight increase in permissiveness for search terms that
 can be normalized by formfield.to_python().
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36865#comment:14>
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/0107019c0fcbd98d-66d74d4d-e171-418c-8d36-b322ccef1fa2-000000%40eu-central-1.amazonses.com.

Reply via email to