diff options
| author | Simon Charette <charette.s@gmail.com> | 2019-10-17 01:57:39 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-24 12:24:53 +0200 |
| commit | 7acef095d73322f45dcceb99afa1a4e50b520479 (patch) | |
| tree | 44390915d053c6789d7263c8c454581909d42fd3 /django/db/models/query.py | |
| parent | e645f27907da0098ee08455d9f1acec14b285f98 (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.py | 5 |
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): |
