#28519: Add filter(), exclude(), and other base QuerySet methods to combined
QuerySets (union(), etc.)
-------------------------------------+-------------------------------------
     Reporter:  Stanislav Karpov     |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  union,               |             Triage Stage:  Accepted
  intersection, difference           |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by harrim4n):

 Until (if) this is implemented, I suggest adding a check when .get(),
 .filter() etc. are called on such a QS. Currently the error messages (if
 there are any) do not explain the issue, the only way to find out about
 this is in the documentation of the QS API, section union().

 Example:
 {{{
 qs1 = User.objects.all()
 qs2 = User.objects.filter(username="nonexistant")
 qs3 = qs1.difference(qs2)
 print(qs1)
 print(qs2)
 print(qs3)
 print(qs1.get(id=1))
 print(qs3.get(id=1))
 }}}

 This fails with (could be any number instead of 4, of course)
 {{{
 MultipleObjectsReturned: get() returned more than one User -- it returned
 4!
 }}}

 Even worse, if the difference of qs1 and qs2 only contains one element,
 this element is returned when calling qs3.get(id=1) without any error
 message, even though the objects ID is not 1.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28519#comment:4>
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/063.db897accf0a8cd68c1797859232537b7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to