#28293: QuerySet.union(QuerySet.none()) results in an empty queryset, should be
the
original queryset
-------------------------------------+-------------------------------------
Reporter: Jon | Owner: nobody
Dufresne |
Type: Bug | Status: new
Component: Database | Version: 1.11
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Tested on Django 1.11.2.
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.
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.0943a2129802e7652685dbf00530cf8e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.