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

Comment (by seddonym):

 I've been looking at correcting the documentation and have just realised
 that one of the statements in the original bug report is wrong: "This
 works correctly for filter() but for exclude() it is operating the same as
 if it was 2 separate exclude() calls."

 Actually, the behaviour is a bit different:

 `Song.objects.exclude(release_set__format='cd',release_set__released=1)`
 would exclude Songs that have ''both'' CD releases ''and'' releases that
 have gone out.

 
`Song.objects.exclude(release_set__format='cd').exclude(release_set__released=1)`,
 on the other hand, would exclude Songs that have ''either'' CD releases
 ''or'' releases that have gone out.

 I've made a gist that sums this up in the form of tests:
 https://gist.github.com/seddonym/84407891a11389419c14

--
Ticket URL: <https://code.djangoproject.com/ticket/14645#comment:16>
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/094.6b909423b0d76c2242fd76b42e06888e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to