#34728: OR operator on queryset does not work as expected
-------------------------------------+-------------------------------------
     Reporter:  Kbleser              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  queryset OR          |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

 Replying to [comment:8 René Fleschenberg]:
 > I understand that this is probably not easy (maybe not possible) for the
 ORM to solve. Maybe I am wrong here, but I think you would expect {{{qs1 |
 qs2}}} to return the same set of results as {{{set(qs1) | set(qs2)}}}? Not
 sure what to do about it, though.

 For this we'd have to use `UNION` instead of combining filters. Queryset
 from the ticket description is really complicated (from the structure
 point of view) with overlap filters, aggregations, filters on aggregated
 values, etc. My point is that you cannot describe it as `Model.filter(x) |
 Model.filter(y)` as it contains aggregations and filters on them. Docs
 don't precise what would happen when you use the `OR` operator on
 `Model.filter(x1).annotate(aggregation).filter(x2) |
 Model.filter(y1).annotate(aggregation).filter(y2)`. If you want to merge
 results of two independent querysets you should use `.union()`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34728#comment:9>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070189783a56cc-0bfc7477-ddba-4be3-a7c7-45a95b6db05e-000000%40eu-central-1.amazonses.com.

Reply via email to