Opened 3 years ago

Closed 13 months ago

#27995 closed Cleanup/optimization (fixed)

Raise a descriptive error on unsupported operations following QuerySet.union(), intersection(), and difference().

Reported by: Tim Graham Owned by: Hasan Ramezani
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The documentation for QuerySet.union() says, "In addition, only LIMIT, OFFSET, and ORDER BY (i.e. slicing and order_by()) are allowed on the resulting QuerySet.", however, there isn't any strict enforcement about this -- some operations like QuerySet.count() might appear to work. See #27982 and #27990 for confusion about this.

Change History (6)

comment:1 Changed 3 years ago by Tim Graham

WIP PR from Florian.

comment:3 Changed 3 years ago by Tim Graham

Summary: Raise a descriptive error on unsupported operations following QuerySet.union()Raise a descriptive error on unsupported operations following QuerySet.union(), intersection(), and difference()

I closed #28328 as a duplicate -- the case of trying to use only() after difference.

comment:4 Changed 15 months ago by felixxm

Summary: Raise a descriptive error on unsupported operations following QuerySet.union(), intersection(), and difference()Raise a descriptive error on unsupported operations following QuerySet.union(), intersection(), and difference().
Version: 1.10master

I closed #30456 as an invalid -- the case of trying to use select_related() after union().

comment:5 Changed 14 months ago by felixxm

I closed #30532 as a duplicate -- the case of trying to use filter() and exclude() after union().

comment:6 Changed 13 months ago by Hasan Ramezani

Has patch: set
Owner: changed from nobody to Hasan Ramezani
Status: newassigned
Last edited 13 months ago by Tim Graham (previous) (diff)

comment:7 Changed 13 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In 18533839:

Fixed #27995 -- Added error messages on unsupported operations following union(), intersection(), and difference().

Note: See TracTickets for help on using tickets.
Back to Top