diff options
| author | Ian Foote <ian@feete.org> | 2018-11-15 14:43:58 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-11-15 09:43:58 -0500 |
| commit | e1fc07c047f8e46c2cea0120f44011fc458f1e91 (patch) | |
| tree | e56a421fe9ea6ff5a053b72c36e914139de2f07b /django | |
| parent | cd40306854bdeec7d961e3715fba0ba9f72f2f88 (diff) | |
Fixed #17930 -- Allowed ORing (|) with sliced QuerySets.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/query.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index 1755bea1a8..b40c768f5c 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -327,8 +327,11 @@ class QuerySet: return other if isinstance(other, EmptyQuerySet): return self - combined = self._chain() + query = self if self.query.can_filter() else self.model._base_manager.filter(pk__in=self.values('pk')) + combined = query._chain() combined._merge_known_related_objects(other) + if not other.query.can_filter(): + other = other.model._base_manager.filter(pk__in=other.values('pk')) combined.query.combine(other.query, sql.OR) return combined |
