#23940: ORM should allow model fields named "exact"
-------------------------------------+-------------------------------------
     Reporter:  zhiyajun11           |                    Owner:
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by jarshwah):

 After doing some investigation with user phood on IRC, the problem seems
 local to fields called `exact` only. We traced the problem to:

 
https://github.com/django/django/blob/d450af8a2687ca2e90a8790eb567f9a25ebce85b/django/db/models/fields/related.py#L684

 The related manager adds a filter called `model__exact` to fetch the
 correct related record. Unfortunately, other parts of the code interpret
 this as targeting the field exact rather than an exact match for the model
 (usually pk).

 Changing:

 {{{
 self.core_filters = {'%s__exact' % rel_field.name: instance}  # old
 self.core_filters = {'%s__pk' % rel_field.name: instance.pk}  # new
 }}}

 Fixes the this problem, but breaks the test:
 
foreign_object.tests.MultiColumnFKTests.test_reverse_query_returns_correct_result

 So, still some work to do here. If there are any multi column fk experts
 around, it'd be good to hear from you.

--
Ticket URL: <https://code.djangoproject.com/ticket/23940#comment:19>
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.bce5144c8ecae5472772bce3172ed296%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to