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
Mariusz Felisiak
6723a26e59
Fixed CVE-2022-28347 -- Protected QuerySet.explain(**options) against SQL injection on PostgreSQL.
2022-04-11 08:59:58 +02:00
Mariusz Felisiak
93cae5cb2f
Fixed CVE-2022-28346 -- Protected QuerySet.annotate(), aggregate(), and extra() against SQL injection in column aliases.
...
Thanks Splunk team: Preston Elder, Jacob Davis, Jacob Moore,
Matt Hanson, David Briggs, and a security researcher: Danylo Dmytriiev
(DDV_UA) for the report.
2022-04-11 08:59:33 +02:00
Gagaro
bf524d229f
Refs #30581 -- Allowed sql.Query to be used without model.
2022-03-16 09:33:16 +01:00
Ryan Heard
c6b4d62fa2
Fixed #29865 -- Added logical XOR support for Q() and querysets.
2022-03-04 12:55:37 +01:00
Albert Defler
2b6a3baebe
Fixed #31486 -- Deprecated passing unsaved objects to related filters.
...
Co-Authored-By: Hasan Ramezani <hasan.r67@gmail.com>
2022-02-25 07:51:37 +01:00
Nick Pope
847f46e9bf
Removed redundant QuerySet.all() calls in docs and tests.
...
Most QuerySet methods are mapped onto the Manager and, in general,
it isn't necessary to call .all() on the manager.
2022-02-22 10:29:38 +01:00
Simon Charette
d35ce682e3
Fixed #33506 -- Made QuerySet.bulk_update() perform atomic writes against write database.
...
The lack of _for_write = True assignment in bulk_update prior to
accessing self.db resulted in the db_for_read database being used to
wrap batched UPDATEs in a transaction.
Also tweaked the batch queryset creation to also ensure they are
executed against the same database as the opened transaction under all
circumstances.
Refs #23646 , #33501 .
2022-02-09 11:14:50 +01:00
Mariusz Felisiak
7119f40c98
Refs #33476 -- Refactored code to strictly match 88 characters line length.
2022-02-07 20:37:05 +01:00
django-bot
9c19aff7c7
Refs #33476 -- Reformatted code with Black.
2022-02-07 20:37:05 +01:00
Mariusz Felisiak
c5cd878382
Refs #33476 -- Refactored problematic code before reformatting by Black.
...
In these cases Black produces unexpected results, e.g.
def make_random_password(
self,
length=10,
allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789',
):
or
cursor.execute("""
SELECT ...
""",
[table name],
)
2022-02-03 11:20:46 +01:00
Jörg Breitbart
0af9a5fc7d
Fixed #33463 -- Fixed QuerySet.bulk_update() with F() expressions.
2022-01-27 19:03:26 +01:00
Mariusz Felisiak
30a0144134
Fixed #29338 -- Allowed using combined queryset in Subquery.
...
Thanks Eugene Kovalev for the initial patch, Simon Charette for the
review, and Chetan Khanna for help.
2022-01-17 18:01:07 +01:00
Ömer Faruk Abacı
81739a45b5
Fixed #33319 -- Fixed crash when combining with the | operator querysets with aliases that conflict.
2021-12-08 21:16:24 +01:00
Hannes Ljungberg
ed2018037d
Fixed #33322 -- Fixed loss of assigned related object when saving relation with bulk_update().
2021-11-29 06:27:22 +01:00
Jonny Park
6fa2930573
Refs #24121 -- Added __repr__() to BaseDatabaseWrapper, JoinPromoter, and SQLCompiler.
2021-11-19 07:57:02 +01:00
Jacob Walls
28f66b2783
Refs #25467 -- Added test for excluding one-to-one relation with unsaved objects.
...
Fixed in 58da81a5a3
.
2021-10-08 06:26:19 +02:00
Jacob Walls
e17ab0af91
Fixed tests.queries.models.StaffUser.__str__().
2021-10-08 06:25:17 +02:00
Mariusz Felisiak
903aaa35e5
Fixed #33159 -- Reverted "Fixed #32970 -- Changed WhereNode.clone() to create a shallow copy of children."
...
This reverts commit e441847eca
.
A shallow copy is not enough because querysets can be reused and
evaluated in nested nodes, which shouldn't mutate JOIN aliases.
Thanks Michal Čihař for the report.
2021-09-30 11:26:17 +02:00