]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Ensure _simple_lazy_clause bind names are fixed before cloning
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 20 Feb 2019 00:46:17 +0000 (19:46 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 20 Feb 2019 00:47:07 +0000 (19:47 -0500)
commit4d2bd4a78fc372c4e08c463cd58dffd1aa891118
tree5a88cf514ec7cbc1d7154e18c13efaa4d05ea0de
parentbce19f26491319338fbd15d874d3c2c4609cf835
Ensure _simple_lazy_clause bind names are fixed before cloning

Fixed a regression in 1.2 due to the introduction of baked queries for
relationship lazy loaders, where a race condition is created during the
generation of the "lazy clause" which occurs within a memoized attribute. If
two threads initialize the memoized attribute concurrently, the baked query
could be generated with bind parameter keys that are then replaced with new
keys by the next run, leading to a lazy load query that specifies the
related criteria as ``None``. The fix establishes that the parameter names
are fixed before the new clause and parameter objects are generated, so that
the names are the same every time.

Fixes: #4507
Change-Id: I605b824e028c87bc20ca8c2577227cdf6a591064
(cherry picked from commit d71f34cb2a28e8dfc410bc5bec68372be6d7c333)
doc/build/changelog/unreleased_12/4507.rst [new file with mode: 0644]
lib/sqlalchemy/orm/strategies.py
test/ext/test_baked.py