diff options
Diffstat (limited to 'django/db/models/query.py')
| -rw-r--r-- | django/db/models/query.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index e1f785f714..1a44523374 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -26,7 +26,7 @@ from django.db.models.deletion import Collector from django.db.models.expressions import Case, F, Value, When from django.db.models.functions import Cast, Trunc from django.db.models.query_utils import FilteredRelation, Q -from django.db.models.sql.constants import CURSOR, GET_ITERATOR_CHUNK_SIZE +from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE, ROW_COUNT from django.db.models.utils import ( AltersData, create_namedtuple_class, @@ -1209,11 +1209,7 @@ class QuerySet(AltersData): """ query = self.query.clone() query.__class__ = sql.DeleteQuery - cursor = query.get_compiler(using).execute_sql(CURSOR) - if cursor: - with cursor: - return cursor.rowcount - return 0 + return query.get_compiler(using).execute_sql(ROW_COUNT) _raw_delete.alters_data = True @@ -1252,7 +1248,7 @@ class QuerySet(AltersData): # Clear any annotations so that they won't be present in subqueries. query.annotations = {} with transaction.mark_for_rollback_on_error(using=self.db): - rows = query.get_compiler(self.db).execute_sql(CURSOR) + rows = query.get_compiler(self.db).execute_sql(ROW_COUNT) self._result_cache = None return rows @@ -1277,7 +1273,7 @@ class QuerySet(AltersData): # Clear any annotations so that they won't be present in subqueries. query.annotations = {} self._result_cache = None - return query.get_compiler(self.db).execute_sql(CURSOR) + return query.get_compiler(self.db).execute_sql(ROW_COUNT) _update.alters_data = True _update.queryset_only = False |
