summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/build/changelog/changelog_11.rst13
-rw-r--r--lib/sqlalchemy/orm/strategies.py4
2 files changed, 17 insertions, 0 deletions
diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst
index 9d43d3ae1..c60550923 100644
--- a/doc/build/changelog/changelog_11.rst
+++ b/doc/build/changelog/changelog_11.rst
@@ -22,6 +22,19 @@
:version: 1.1.7
.. change::
+ :tags: bug, orm
+ :tickets: 3947
+ :versions: 1.2.0b1
+
+ 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::
:tags: bug, sql, postgresql
:tickets: 2892
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)