From a0bd0063065de054c73d5984d7b4830e29e809e6 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Thu, 14 Apr 2022 07:53:15 +0200 Subject: Made select_for_update() don't raise TransactionManagementError on databases that don't support transactions. --- django/db/models/sql/compiler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'django/db/models/sql/compiler.py') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index faa08e376d..1285b647d8 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -653,7 +653,12 @@ class SQLCompiler: params.extend(f_params) if self.query.select_for_update and features.has_select_for_update: - if self.connection.get_autocommit(): + if ( + self.connection.get_autocommit() + # Don't raise an exception when database doesn't + # support transactions, as it's a noop. + and features.supports_transactions + ): raise TransactionManagementError( "select_for_update cannot be used outside of a transaction." ) -- cgit v1.3