diff options
author | 4the4ryushin <aman2001mi@gmail.com> | 2023-04-28 02:33:25 +0530 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-05-01 10:20:20 +0200 |
commit | 0b0998dc151feb77068e2387c34cc50ef6b356ae (patch) | |
tree | 89076756b666cc024ec22d81f299400cdf52aaad /django/db/models/sql/compiler.py | |
parent | 5a6d4d3bfde07daab9777545694beb014c832264 (diff) | |
download | django-0b0998dc151feb77068e2387c34cc50ef6b356ae.tar.gz |
Fixed #33759 -- Avoided unnecessary subquery in QuerySet.delete() with self-referential subqueries if supported.
Diffstat (limited to 'django/db/models/sql/compiler.py')
-rw-r--r-- | django/db/models/sql/compiler.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 07393e7605..a7a8c98b99 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -1890,7 +1890,10 @@ class SQLDeleteCompiler(SQLCompiler): Create the SQL for this query. Return the SQL string and list of parameters. """ - if self.single_alias and not self.contains_self_reference_subquery: + if self.single_alias and ( + self.connection.features.delete_can_self_reference_subquery + or not self.contains_self_reference_subquery + ): return self._as_sql(self.query) innerq = self.query.clone() innerq.__class__ = Query |