#17600: Error in encapsulates filters (Q)
-------------------------------------+-------------------------------------
     Reporter:  pmartin              |                    Owner:  nobody
         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:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by anonymous):

 It seems this isn't easy to fix.

 First, my previous comment is bogus - `the items__in` query actually
 generates two subqueries, the generated queries are:
 {{{
 the items__in one:
 SELECT DISTINCT "excludes_order"."id" FROM "excludes_order"
 WHERE NOT ("excludes_order"."id" IN
     (SELECT U1."order_id" FROM "excludes_orderitem" U1 WHERE (U1."id" IN
         (SELECT U0."id" FROM "excludes_orderitem" U0 WHERE NOT
 (U0."status" = 1 ))
      AND U1."order_id" IS NOT NULL)))
 ORDER BY "excludes_order"."id" ASC

 and the erroneous current one:
 SELECT DISTINCT "excludes_order"."id" FROM "excludes_order" WHERE NOT (NOT
 ("excludes_order"."id" IN
     (SELECT U1."order_id" FROM "excludes_orderitem" U1 WHERE (U1."status"
 = 1  AND U1."order_id" IS NOT NULL))))
 ORDER BY "excludes_order"."id" ASC
 }}}

 It is somewhat hard to generate the correct query, as when the need for
 the subquery is seen, the NOT is already added to the tree. This will be
 easier to handle if the add_q logic is arranged in a way where the lookups
 are checked for multijoins before beginning to add them into the query, so
 that one can push the NOT into the subquery. Still, I don't believe this
 to be easy to fix even then, as the subquery generation needs added logic
 to support nested subqueries.

 So, I think this test should be added to regressiontests/queries as an
 @expectedFailure.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17600#comment:20>
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 this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to