summaryrefslogtreecommitdiff
path: root/tests/queries/test_qs_combinators.py
AgeCommit message (Collapse)Author
2026-02-12Added tests for QuerySet.union() across different models and value aliases.Emanuel Lupi
These tests were developed during work on MongoDB and capture edge cases discovered there.
2026-02-06Refs #36644 -- Applied default ordering after union().Nilesh Kumar Pahari
2026-01-27Refs #35744 -- Removed problematic __in lookup in ↵Tim Graham
test_intersection_in_nested_subquery. It's problematic on MongoDB. Simon: "It seems odd that we'd use __in=OuterRef("pk") over __in=[OuterRef("pk")]. It's a SQLism that only works because right-hand-side is wrapped with (...) and that's interpreted as a singleton tuple which is allowed with IN."
2025-05-19Fixed #36388 -- Made QuerySet.union() return self when called with no arguments.Colleen Dunlap
Regression in 9cb8baa0c4fa2c10789c5c8b65f4465932d4d172. Thank you to Antoine Humeau for the report and Simon Charette for the review.
2024-11-08Fixed #35011, Refs #28900 -- Added tests for QuerySet.union() with multiple ↵Jacob Rief
models and DateTimeField annotations. Ticket was resolved by 65ad4ade74dc9208b9d686a451cd6045df0c9c3a as part of #28900.
2024-10-14Fixed #35744 -- Relabelled external aliases of combined queries.Simon Charette
Just like normal queries, combined queries' outer references might fully resolve before their reference is assigned its final alias. Refs #29338. Thanks Antony_K for the report and example, and thanks Mariusz Felisiak for the review.
2024-07-19Fixed #35559 -- Avoided unnecessary query on sliced union of empty queries.Simon Charette
While refs #34125 focused on the SQL correctness of slicing of union of potentially empty queries it missed an optimization opportunity to avoid performing a query at all when all queries are empty. Thanks Lucidiot for the report.
2024-07-03Fixed #28900 -- Propagated all selected fields to combinator queries.Simon Charette
Previously, only the selected column aliases would be propagated and annotations were ignored.
2024-07-03Refs #28900 -- Made SELECT respect the order specified by values(*selected).Simon Charette
Previously the order was always extra_fields + model_fields + annotations with respective local ordering inferred from the insertion order of *selected. This commits introduces a new `Query.selected` propery that keeps tracks of the global select order as specified by on values assignment. This is crucial feature to allow the combination of queries mixing annotations and table references. It also allows the removal of the re-ordering shenanigans perform by ValuesListIterable in order to re-map the tuples returned from the database backend to the order specified by values_list() as they'll be in the right order at query compilation time. Refs #28553 as the initially reported issue that was only partially fixed for annotations by d6b6e5d0fd4e6b6d0183b4cf6e4bd4f9afc7bf67. Thanks Mariusz Felisiak and Sarah Boyce for review.
2023-12-16Refs #34013 -- Registered instance lookups as documented in tests.Simon Charette
2023-12-12Fixed #34013 -- Added QuerySet.order_by() support for annotation transforms.Simon Charette
Thanks Eugene Morozov and Ben Nace for the reports.
2023-03-24Fixed #28553 -- Fixed annotation mismatch with ↵David Wobrock
QuerySet.values()/values_list() on compound queries. Co-authored-by: Matthias Kestenholz <mk@feinheit.ch>
2023-02-21Refs #31445 -- Added test for nesting QuerySet.union().Mariusz Felisiak
This was fixed in MySQL 8.0.31.
2023-01-20Fixed #34267 -- Fixed sliced QuerySet.union() crash.Francesco Panico
Regression in 3d734c09ff0138441dfe0a59010435871d17950f. Thanks Raphaël Stefanini for the report.
2022-11-23Refs #33050 -- Added test for QuerySet.count() on combined queries with ↵Mariusz Felisiak
select_related(). Thanks Simon Charette for noticing this. Fixed in 70499b25c708557fb9ee2264686cd172f4b2354e.
2022-11-15Fixed #34123 -- Fixed combinator order by alias when using select_related().Simon Charette
Regression in c58a8acd413ccc992dd30afd98ed900897e1f719. Thanks to Shai Berger for the report and tests. Co-Authored-By: David Sanders <shang.xiao.sanders@gmail.com>
2022-10-29Fixed #34125 -- Fixed sliced QuerySet.union() crash on a single non-empty ↵Simon Charette
queryset. The bug existed since sliced query union was added but was elevated to query union slices by moving the .exists() optimization to the compiler in 3d734c09ff0138441dfe0a59010435871d17950f. Thanks Stefan Hammer for the report.
2022-10-08Refs #33990 -- Renamed TransactionTestCase.assertQuerysetEqual() to ↵Gregor Gärtner
assertQuerySetEqual(). Co-Authored-By: Michael Howitz <mh@gocept.com>
2022-10-05Fixed #33768 -- Fixed ordering compound queries by nulls_first/nulls_last on ↵Simon Charette
MySQL. Columns of the left outer most select statement in a combined query can be referenced by alias just like by index. This removes combined query ordering by column index and avoids an unnecessary usage of RawSQL which causes issues for backends that specialize the treatment of null ordering.
2022-06-27Fixed #33796 -- Fixed ordered combined queryset crash when used in subquery ↵Mariusz Felisiak
on PostgreSQL and MySQL. Thanks Shai Berger for the report. Regression in 30a01441347d5a2146af2944b29778fa0834d4be.
2022-03-04Fixed #29865 -- Added logical XOR support for Q() and querysets.Ryan Heard
2022-02-22Removed redundant QuerySet.all() calls in docs and tests.Nick Pope
Most QuerySet methods are mapped onto the Manager and, in general, it isn't necessary to call .all() on the manager.
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2022-01-17Fixed #29338 -- Allowed using combined queryset in Subquery.Mariusz Felisiak
Thanks Eugene Kovalev for the initial patch, Simon Charette for the review, and Chetan Khanna for help.
2021-09-24Fixed #33127 -- Added error messages on | and & operators with combined ↵Hasan Ramezani
querysets.
2021-04-12Fixed #32627 -- Fixed QuerySet.values()/values_list() crash on combined ↵Iuri de Silvio
querysets ordered by unannotated columns.
2021-03-06Fixed #24141 -- Added QuerySet.contains().Johan Schiff
2020-11-16Fixed #31507 -- Added QuerySet.exists() optimizations to compound queries.David-Wobrock
2020-11-16Refs #27718 -- Doc'd and tested QuerySet.exists() for combined querysets.David-Wobrock
Supported since 84c1826ded17b2d74f66717fb745fc36e37949fd.
2020-11-14Fixed #31496 -- Fixed QuerySet.values()/values_list() crash on combined ↵David-Wobrock
querysets ordered by annotations.
2020-10-19Fixed #32116 -- Fixed QuerySet.order_by() crash on EmptyQuerySet with ↵Hannes Ljungberg
union() on a single non-empty ordered queryset.
2020-10-05Fixed #32068 -- Added error messages on get() with filters following ↵Hasan Ramezani
union(), intersection(), and difference().
2020-10-05Refs #32068 -- Added tests for get() following union(), intersection(), and ↵Hasan Ramezani
difference().
2020-09-17Fixed #31916 -- Fixed combined queryset crash when combining with ordered ↵Hasan Ramezani
combined querysets.
2020-07-31Fixed #27719 -- Added QuerySet.alias() to allow creating reusable aliases.Alexandr Tatarinov
QuerySet.alias() allows creating reusable aliases for expressions that don't need to be selected but are used for filtering, ordering, or as a part of complex expressions. Thanks Simon Charette for reviews.
2020-07-07Fixed #31767 -- Fixed QuerySet.none() on combined queryset.Mariusz Felisiak
2020-05-27Refs #31614 -- Added test for ordering by OrderBy() of combined queryset ↵Mariusz Felisiak
with not selected columns.
2020-05-26Fixed #31614 -- Fixed aliases ordering by OrderBy() expressions of combined ↵Laurent Tramoy
queryset.
2020-05-26Refs #31614 -- Added test for aliases ordering on combined querysets.Laurent Tramoy
2020-05-26Used operator.attrgetter() in test_qs_combinators.Laurent Tramoy
2020-05-13Fixed #31580 -- Added error messages on distinct() following union(), ↵Hasan Ramezani
intersection(), and difference().
2020-02-04Simplified imports from django.db and django.contrib.gis.db.Nick Pope
2020-01-09Fixed #31148 -- Added error messages on update()/delete() operations ↵Hasan Ramezani
following union(), intersection(), and difference().
2019-07-25Fixed #27995 -- Added error messages on unsupported operations following ↵Hasan Ramezani
union(), intersection(), and difference().
2019-07-10Fixed #30628 -- Adjusted expression identity to differentiate bound fields.Simon Charette
Expressions referring to different bound fields should not be considered equal. Thanks Julien Enselme for the detailed report. Regression in bc7e288ca9554ac1a0a19941302dea19df1acd21.
2019-06-19Fixed #29834 -- Fixed column mismatch crash with ↵can
QuerySet.values()/values_list() and order_by() on combined querysets.
2019-06-19Fixed #30572 -- Prevented values()/values_list() on combined queryset from ↵Mariusz Felisiak
mutating the list of columns in querysets.
2019-01-14Fixed #30093 -- Fixed ordering of combined queryset ordered by F expressions.Sergey Fedoseev
2018-12-06Fixed #29932 -- Fixed combining compound queries with sub-compound queries ↵Mariusz Felisiak
on SQLite and Oracle.
2018-08-29Fixed #29694 -- Fixed column mismatch crash with QuerySet.values() or ↵Mariusz Felisiak
values_list() after combining querysets with extra() with union(), difference(), or intersection(). Regression in 0b66c3b442875627fa6daef4ac1e90900d74290b.