diff options
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/compiler.py | 13 | ||||
| -rw-r--r-- | django/db/models/sql/query.py | 1 |
2 files changed, 11 insertions, 3 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index c368a59226..29e33c075f 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -546,19 +546,26 @@ class SQLCompiler: nowait = self.query.select_for_update_nowait skip_locked = self.query.select_for_update_skip_locked of = self.query.select_for_update_of - # If it's a NOWAIT/SKIP LOCKED/OF query but the backend - # doesn't support it, raise NotSupportedError to prevent a - # possible deadlock. + no_key = self.query.select_for_no_key_update + # If it's a NOWAIT/SKIP LOCKED/OF/NO KEY query but the + # backend doesn't support it, raise NotSupportedError to + # prevent a possible deadlock. if nowait and not self.connection.features.has_select_for_update_nowait: raise NotSupportedError('NOWAIT is not supported on this database backend.') elif skip_locked and not self.connection.features.has_select_for_update_skip_locked: raise NotSupportedError('SKIP LOCKED is not supported on this database backend.') elif of and not self.connection.features.has_select_for_update_of: raise NotSupportedError('FOR UPDATE OF is not supported on this database backend.') + elif no_key and not self.connection.features.has_select_for_no_key_update: + raise NotSupportedError( + 'FOR NO KEY UPDATE is not supported on this ' + 'database backend.' + ) for_update_part = self.connection.ops.for_update_sql( nowait=nowait, skip_locked=skip_locked, of=self.get_select_for_update_of_arguments(), + no_key=no_key, ) if for_update_part and self.connection.features.for_update_after_from: diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 375e22c4de..ce18098fd2 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -189,6 +189,7 @@ class Query(BaseExpression): self.select_for_update_nowait = False self.select_for_update_skip_locked = False self.select_for_update_of = () + self.select_for_no_key_update = False self.select_related = False # Arbitrary limit for select_related to prevents infinite recursion. |
