]> 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:46:17 +0000 (19:46 -0500)
commitd71f34cb2a28e8dfc410bc5bec68372be6d7c333
tree975747f157b1df1f36c7ee7ec4bf019afb55dff8
parentc0bd36873b3879747f2d094696fb0bc19c0539ff
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
doc/build/changelog/unreleased_12/4507.rst [new file with mode: 0644]
lib/sqlalchemy/orm/strategies.py
test/ext/test_baked.py