Alex Fischer
c6a4f853c7
Fixed #35712 -- Prevented Q.check() from leaving the connection in an unusable state.
...
Co-authored-by: Simon Charette <charette.s@gmail.com>
2024-09-02 17:00:55 +02:00
Tim Graham
6a85c888bf
Added supports_select_union skips in queries and aggregation tests.
2024-08-26 12:53:08 -03:00
Simon Charette
9cb8baa0c4
Fixed #35559 -- Avoided unnecessary query on sliced union of empty queries.
...
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-19 08:54:47 +02:00
Simon Charette
6d220963fa
Fixed #28900 -- Propagated all selected fields to combinator queries.
...
Previously, only the selected column aliases would be propagated and
annotations were ignored.
2024-07-03 16:36:25 +02:00
Simon Charette
65ad4ade74
Refs #28900 -- Made SELECT respect the order specified by values(*selected).
...
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 d6b6e5d0fd
.
Thanks Mariusz Felisiak and Sarah Boyce for review.
2024-07-03 16:36:25 +02:00
David Sanders
97d48cd3c6
Refs #34007 , Refs #35359 -- Added Q.referenced_based_fields property.
...
Thank you to Mariusz Felisiak and Natalia Bidart for the reviews.
2024-05-02 19:05:13 +02:00
Adam Johnson
cbf1e87398
Fixed #35294 -- Fixed TEXT format of QuerySet.explain() for long plans.
...
co-authored-by: Gordon <gordon.wrigley@gmail.com>
co-authored-by: Simon Charette <charette.s@gmail.com>
2024-03-15 06:58:14 +01:00
Hisham Mahmood
d79fba7d8e
Fixed #35099 -- Prevented mutating queryset when combining with & and | operators.
...
Thanks Alan for the report.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2024-02-07 12:36:30 +01:00
Mariusz Felisiak
305757aec1
Applied Black's 2024 stable style.
...
https://github.com/psf/black/releases/tag/24.1.0
2024-01-26 12:45:07 +01:00
Simon Charette
eea4f92f9a
Refs #34013 -- Registered instance lookups as documented in tests.
2023-12-16 20:05:36 +01:00
Simon Charette
b0ad41198b
Fixed #34013 -- Added QuerySet.order_by() support for annotation transforms.
...
Thanks Eugene Morozov and Ben Nace for the reports.
2023-12-12 05:51:33 +01:00
Nick Pope
1c3614e306
Refs #34986 -- Avoided implementation-specific unpickleable types.
...
The implementation of some core types differ between CPython and PyPy
and this may affect the way that pickling works such that errors are
raised in differing locations in the interpreter or not at all.
Use our own custom non-pickleable type instead to avoid these quirks.
2023-12-06 09:23:35 +01:00
Mariusz Felisiak
f9e9526800
Fixed #34873 -- Added QuerySet.explain() support for GENERIC_PLAN option on PostgreSQL 16+.
2023-09-26 12:05:26 +02:00
Mariusz Felisiak
2c6ebb65c9
Fixed #34851 -- Dropped support for PostgreSQL 12 and PostGIS 2.5.
2023-09-20 13:45:51 +02:00
David Sanders
76c3e310dd
Fixed #34744 -- Prevented recreation of migration for constraints with a dict_keys.
...
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2023-08-23 11:42:18 +02:00
Mariusz Felisiak
e69a9920e2
Fixed non-deterministic order in SubqueryTests.test_slice_subquery_and_query.
...
Slice on unordered subquery may be non-deterministic in some databases.
2023-08-10 05:33:13 +02:00
Simon Charette
1c4f5f314e
Refs #32143 -- Removed superflous constraints on excluded query.
...
The outer query reference is not necessary when alias can be reused and
can even be harmful by confusing query planers.
Refs #34597 .
2023-06-14 09:44:49 +02:00
David Wobrock
d6b6e5d0fd
Fixed #28553 -- Fixed annotation mismatch with QuerySet.values()/values_list() on compound queries.
...
Co-authored-by: Matthias Kestenholz <mk@feinheit.ch>
2023-03-24 06:09:27 +01:00
Mariusz Felisiak
96bc4254ee
Refs #31445 -- Added test for nesting QuerySet.union().
...
This was fixed in MySQL 8.0.31.
2023-02-21 12:47:52 +01:00
Francesco Panico
cc8aa6bf9c
Fixed #34267 -- Fixed sliced QuerySet.union() crash.
...
Regression in 3d734c09ff
.
Thanks Raphaël Stefanini for the report.
2023-01-20 08:51:38 +01:00
Mariusz Felisiak
4d78d7338c
Refs #31486 -- Removed ability to pass unsaved model instances to related filters.
...
Per deprecation timeline.
2023-01-17 11:49:15 +01:00
Mariusz Felisiak
3b24a3fa33
Removed unnecessary commas in tests.
2022-12-21 11:41:29 +01:00
Florian Apolloner
3e3b7f691b
Refs #33308 -- Avoided passing None to RawSQL's params.
...
Passing None to params causes errors in determining the data type on
psycopg3.
2022-12-02 10:56:09 +01:00
Mariusz Felisiak
a411b90967
Refs #33050 -- Added test for QuerySet.count() on combined queries with select_related().
...
Thanks Simon Charette for noticing this.
Fixed in 70499b25c7
.
2022-11-23 09:35:48 +01:00
Simon Charette
70499b25c7
Fixed #34123 -- Fixed combinator order by alias when using select_related().
...
Regression in c58a8acd41
.
Thanks to Shai Berger for the report and tests.
Co-Authored-By: David Sanders <shang.xiao.sanders@gmail.com>
2022-11-15 10:48:19 +01:00
Simon Charette
76e37513e2
Refs #33374 -- Adjusted full match condition handling.
...
Adjusting WhereNode.as_sql() to raise an exception when encoutering a
full match just like with empty matches ensures that all case are
explicitly handled.
2022-11-07 20:23:53 +01:00
David Wobrock
a320aab512
Fixed #16211 -- Added logical NOT support to F expressions.
2022-10-31 09:55:51 +01:00
Simon Charette
c2cc80756b
Fixed #34125 -- Fixed sliced QuerySet.union() crash on a single non-empty 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 3d734c09ff
.
Thanks Stefan Hammer for the report.
2022-10-29 09:21:25 +02:00
Gregor Gärtner
f0c06f8ab7
Refs #33990 -- Renamed TransactionTestCase.assertQuerysetEqual() to assertQuerySetEqual().
...
Co-Authored-By: Michael Howitz <mh@gocept.com>
2022-10-08 08:07:38 +02:00
Mariusz Felisiak
d795259ea9
Replaced assertQuerysetEqual() to assertSequenceEqual()/assertCountEqual() where appropriate.
...
Follow up to 3f7b327562
.
2022-10-07 13:05:35 +02:00
Simon Charette
c58a8acd41
Fixed #33768 -- Fixed ordering compound queries by nulls_first/nulls_last on 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-10-05 14:04:49 +02:00
David Sanders
4771a1694b
Fixed #34012 -- Made QuerySet.order_by() apply transforms on related fields for models with Meta.ordering.
...
This makes QuerySet.order_by() no longer ignore trailing transforms for
models with Meta.ordering. As a consequence, FieldError is raised in
such cases for non-existent fields.
Thanks to Klaas van Schelven for the report and Mariusz Felisiak for the
review and advice.
2022-10-04 08:19:34 +02:00
Mariusz Felisiak
37a13cc92d
Refs #34012 -- Added test for ordering by transform of related fields.
2022-09-22 12:55:47 +02:00
Mariusz Felisiak
ce6230aa97
Fixed #34015 -- Allowed filtering by transforms on relation fields.
2022-09-22 00:17:04 +02:00
Simon Charette
b3db6c8dcb
Fixed #21204 -- Tracked field deferrals by field instead of models.
...
This ensures field deferral works properly when a model is involved
more than once in the same query with a distinct deferral mask.
2022-08-30 08:43:53 +02:00
Nick Pope
9dff316be4
Refs #32948 , Refs #32946 -- Used Q.create() internally for dynamic Q() objects.
...
Node.create() which has a compatible signature with Node.__init__()
takes in a single `children` argument rather than relying in unpacking
*args in Q.__init__() which calls Node.__init__().
In addition, we were often needing to unpack iterables into *args and
can instead pass a list direct to Node.create().
2022-07-27 10:06:24 +02:00
Nick Pope
769d7cce4a
Used AND, OR, XOR constants instead of hard-coded values.
2022-07-27 07:55:09 +02:00
Mariusz Felisiak
44ffd8d06f
Fixed #33796 -- Fixed ordered combined queryset crash when used in subquery on PostgreSQL and MySQL.
...
Thanks Shai Berger for the report.
Regression in 30a0144134
.
2022-06-27 06:21:31 +02:00
Ebram Shehata
4996eaa7b5
Made QuerySet.bulk_update() raise an error when batch_size is zero.
2022-06-13 06:25:25 +02:00
Mariusz Felisiak
981c23c0cc
Fixed #33717 -- Dropped support for PostgreSQL 11.
2022-05-19 09:26:48 +02:00
Gagaro
5d91dc8ee3
Refs #30581 -- Added Q.check() hook.
2022-05-04 08:47:52 +02:00
Gagaro
9d04711261
Refs #30581 -- Added Q.flatten().
2022-05-03 15:31:53 +02:00
Mariusz Felisiak
f4f2afeb45
Refs #32226 -- Fixed JSON format of QuerySet.explain() on PostgreSQL when format is uppercased.
...
Follow up to aba9c2de66
.
2022-04-19 08:24:24 +02:00
Mariusz Felisiak
1760ad4e8c
Relaxed some query ordering assertions in various tests.
...
It accounts for differences seen on MySQL with MyISAM storage engine.
2022-04-14 12:12:13 +02:00
Mariusz Felisiak
a0bd006306
Made select_for_update() don't raise TransactionManagementError on databases that don't support transactions.
2022-04-14 07:53:15 +02:00
Tim Graham
db83ac48d4
Expanded QuerySet.explain() error message if a backend supports no formats.
2022-04-14 06:46:42 +02:00
Mariusz Felisiak
0b63124c84
Improved ExplainTests.test_basic().
...
QuerySet.select_for_update() is not supported by all databases.
Moreover it cannot be used outside of a transaction.
2022-04-13 10:17:14 +02:00
mgaligniana
0ad5316f22
Fixed #24296 -- Made QuerySet.exists() clear selected columns for not sliced distinct querysets.
2022-04-12 08:18:22 +02:00
mgaligniana
d2263b7b87
Refs #18414 -- Added tests for selected columns of sliced distinct querysets.
2022-04-12 08:18:22 +02:00
Mariusz Felisiak
b8759093d8
Removed DatabaseFeatures.validates_explain_options.
...
Always True since 6723a26e59
.
2022-04-11 12:58:01 +02:00