]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Render FOR UPDATE on the inner subquery as well as the outer
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 30 Apr 2018 15:31:48 +0000 (11:31 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 2 May 2018 00:52:44 +0000 (20:52 -0400)
commit453cdfd75688e869637f0bbd171594e1fe7b6a39
tree753529237e0aa2792252bf78554c81cbc0b04b05
parent29c5f7a5d5dae47bef823804096cb4a7122ff8fa
Render FOR UPDATE on the inner subquery as well as the outer

The ORM now doubles the "FOR UPDATE" clause within the subquery that
renders in conjunction with joined eager loading in some cases, as it has
been observed that MySQL does not lock the rows from a subquery.   This
means the query renders with two FOR UPDATE clauses; note that on some
backends such as Oracle, FOR UPDATE clauses on subqueries are silently
ignored since they are unnecessary.  Additionally, in the case of the "OF"
clause used primarily with Postgresql, the FOR UPDATE is rendered only on
the inner subquery when this is used so that the selectable can be targeted
to the table within the SELECT statement.

Change-Id: Ie5520d08d82bf0afd9e1bd2d43a0b2a0db0de16d
Fixes: #4246
doc/build/changelog/migration_13.rst
doc/build/changelog/unreleased_13/4246.rst [new file with mode: 0644]
lib/sqlalchemy/orm/query.py
test/dialect/mysql/test_for_update.py [new file with mode: 0644]
test/orm/test_lockmode.py