#16955: Querying on the reverse of a FK with the wrong class silently returns 
bad
data
-------------------------------------+-------------------------------------
     Reporter:  jdunck               |                    Owner:  dgouldin
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.3
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:                       |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  1
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 This will be horrible to fix. At least the following work currently, also
 with multistep chains:
 {{{
 parent__in=list_of_childs
 child__in=list_of_parents

 class A:
     pass

 class B:
     a = models.OneToOneField(A, primary_key=True)

 a__in=list_of_B
 b__in=list_of_A
 }}}

 This means that we must check issubclass in two directions + primary key
 chain from value to the related model, and from related model to value.

 The sanest fixes would be to precalculate a set of allowed models in
 Model._meta. The calculation of the set of allowed models will still be
 ugly, but at least checking would be somewhat fast... Patches welcome.

 Another way is to disallow the OneToOneField related lookups. The
 issubclass checks are easy to do.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16955#comment:11>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to