#14645: Exclude query with multiple conditions for the same multi-value relation
not correct
-------------------------------------+-------------------------------------
     Reporter:  Ben Buchwald         |                    Owner:  nobody
  <bb2@…>                            |                   Status:  new
         Type:  Bug                  |                  Version:  master
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:  Accepted
     Severity:  Normal               |      Needs documentation:  0
     Keywords:  exclude manytomany   |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by chriskrusz):

 * version:  1.3 => master


Comment:

 Still present in master.

 You can get SQL which returns what you would expect using this:

 {{{
 
Song.objects.exclude(id__in=Release.objects.filter(format='cd',released=1).values('song'))
 }}}

 This gives the query you would expect originally:
 {{{
 SELECT "songs_song"."id", "songs_song"."name" FROM "songs_song"
 WHERE NOT (
     "songs_song"."id" IN (
         SELECT U0."song_id"
         FROM "songs_release" U0
         WHERE (U0."released" = True  AND U0."format" = cd)
     )
 )
 }}}

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


Reply via email to