summaryrefslogtreecommitdiff
path: root/django/db/models/query.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2019-10-17 01:57:39 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-24 12:24:53 +0200
commit7acef095d73322f45dcceb99afa1a4e50b520479 (patch)
tree44390915d053c6789d7263c8c454581909d42fd3 /django/db/models/query.py
parente645f27907da0098ee08455d9f1acec14b285f98 (diff)
Fixed #23576 -- Implemented multi-alias fast-path deletion in MySQL backend.
This required moving the entirety of DELETE SQL generation to the compiler where it should have been in the first place and implementing a specialized compiler on MySQL/MariaDB. The MySQL compiler relies on the "DELETE table FROM table JOIN" syntax for queries spanning over multiple tables.
Diffstat (limited to 'django/db/models/query.py')
-rw-r--r--django/db/models/query.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index b61c76f80f..bb0bc4da63 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -744,7 +744,10 @@ class QuerySet:
Delete objects found from the given queryset in single direct SQL
query. No signals are sent and there is no protection for cascades.
"""
- return sql.DeleteQuery(self.model).delete_qs(self, using)
+ query = self.query.clone()
+ query.__class__ = sql.DeleteQuery
+ cursor = query.get_compiler(using).execute_sql(CURSOR)
+ return cursor.rowcount if cursor else 0
_raw_delete.alters_data = True
def update(self, **kwargs):