As `QuerySet.union()` uses the SQL `UNION` operator, I would expect "SET1
UNION <EMPTY SET>" to result in SET1. Currently it results in the empty
set.
{{{
>>> from django.contrib.auth.models import User
>>> User.objects.count()
100
>>> list(User.objects.all().union(User.objects.none()))
[]
}}}
From https://www.postgresql.org/docs/current/static/queries-union.html
> UNION effectively appends the result of query2 to the result of query1
...
`QuerySet.difference()` looks to suffer from the same issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/28293>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
Marking as ''Release blocker'' since it's a bug in a newly introduced
feature.
--
Ticket URL: <https://code.djangoproject.com/ticket/28293#comment:1>
* owner: nobody => felixxm
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/28293#comment:2>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/8629 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/28293#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"82175ead723f8fa3f9271fbd4b24275097029aab" 82175ead]:
{{{
#!CommitTicketReference repository=""
revision="82175ead723f8fa3f9271fbd4b24275097029aab"
Fixed #28293 -- Fixed union(), intersection(), and difference() when
combining with an EmptyQuerySet.
Thanks Jon Dufresne for the report and Tim Graham for the review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28293#comment:4>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"44e29ea1e906859e85bb2a46ae5ea9d82bd96f5f" 44e29ea1]:
{{{
#!CommitTicketReference repository=""
revision="44e29ea1e906859e85bb2a46ae5ea9d82bd96f5f"
[1.11.x] Fixed #28293 -- Fixed union(), intersection(), and difference()
when combining with an EmptyQuerySet.
Thanks Jon Dufresne for the report and Tim Graham for the review.
Backport of 82175ead723f8fa3f9271fbd4b24275097029aab from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28293#comment:5>