summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-03-25 22:17:17 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-03-25 22:17:17 -0400
commitf214f4d4f46de24008c63f2e034329a64f510833 (patch)
tree59200aebb59d24b30df971dd02d6ecbb4efc75e8 /lib/sqlalchemy
parent0883d8213bcfbeb5e0ae6dd1cbcf70494eb06dac (diff)
downloadsqlalchemy-f214f4d4f46de24008c63f2e034329a64f510833.tar.gz
Pre-load alias.c within JoinedEagerLoader cached AliasedClass
Fixed a race condition which could occur under threaded environments as a result of the caching added via :ticket:`3915`. An internal collection of ``Column`` objects could be regenerated on an alias object inappropriately, confusing a joined eager loader when it attempts to render SQL and collect results and resulting in an attribute error. The collection is now generated up front before the alias object is cached and shared among threads. Change-Id: I97d5b205992d38af8d2b4307178a15c086ef9993 Fixes: #3947
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/strategies.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py
index caf0da340..c70994e8f 100644
--- a/lib/sqlalchemy/orm/strategies.py
+++ b/lib/sqlalchemy/orm/strategies.py
@@ -1309,6 +1309,10 @@ class JoinedLoader(AbstractRelationshipLoader):
self.mapper,
flat=True,
use_mapper_path=True)
+ # load up the .columns collection on the Alias() before
+ # the object becomes shared among threads. this prevents
+ # races for column identities.
+ inspect(to_adapt).selectable.c
self._aliased_class_pool.append(to_adapt)