summaryrefslogtreecommitdiff
path: root/django/db/models/sql/compiler.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-04-14 07:53:15 +0200
committerGitHub <noreply@github.com>2022-04-14 07:53:15 +0200
commita0bd0063065de054c73d5984d7b4830e29e809e6 (patch)
treee6bb875b62ce3aced78237c66170adbc2d5b62d1 /django/db/models/sql/compiler.py
parentdb83ac48d4015ce3487405481426c3d2d38335df (diff)
downloaddjango-a0bd0063065de054c73d5984d7b4830e29e809e6.tar.gz
Made select_for_update() don't raise TransactionManagementError on databases that don't support transactions.
Diffstat (limited to 'django/db/models/sql/compiler.py')
-rw-r--r--django/db/models/sql/compiler.py7
1 files changed, 6 insertions, 1 deletions
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."
)