﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24880	Clarify docs about select_for_update() error if run outside of a transaction	Przemysław Suliga	nobody	"A `TransactionManagementError` is now raised when `select_for_update` is executed in autocommit mode - but only on backends that support `SELECT ... FOR UPDATE`. Perhaps it should be raised also on backends that do not support `SELECT ... FOR UPDATE`?

Reading the documentation:

> Evaluating a queryset with select_for_update() in autocommit mode is a TransactionManagementError error because the rows are not locked in that case. If allowed, this would facilitate data corruption and could easily be caused by calling code that expects to be run in a transaction outside of one.

> Using select_for_update() on backends which do not support SELECT ... FOR UPDATE (such as SQLite) will have no effect.


It's not 100% clear if the error will be raised on backends that do not support `SELECT ... FOR UPDATE`. I was confused by this and assumed that it **will** error on `sqlite` - it does not.


Here's a rough patch that will make `select_for_update` error on all backends in that case: https://github.com/django/django/compare/master...suligap:select_for_update-transaction-error-on-all-backends

Alternatively, if this does not make sense due to reasons I don't understand ATM, maybe we could make the docs be more explicit about this aspect."	Cleanup/optimization	closed	Documentation	dev	Normal	fixed			Accepted	1	0	0	0	0	0
