summaryrefslogtreecommitdiff
path: root/test/orm/test_utils.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-06-27 00:40:34 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-06-27 00:40:34 -0400
commitfcb7c784e9479b9bff7de20c41a05bc1aa550ffb (patch)
tree31069380bd348fce6b2b71d6e5330fe65f231e6f /test/orm/test_utils.py
parent012b3bd0b2a0e9cdfd11d797b6aa0053a13816b0 (diff)
downloadsqlalchemy-fcb7c784e9479b9bff7de20c41a05bc1aa550ffb.tar.gz
- Fixed 1.0 regression where the "parent entity" of a synonym-
mapped attribute on top of an :func:`.aliased` object would resolve to the original mapper, not the :func:`.aliased` version of it, thereby causing problems for a :class:`.Query` that relies on this attribute (e.g. it's the only representative attribute given in the constructor) to figure out the correct FROM clause for the query. fixes #3466 - apply consitency to ._parententity vs. __clause_element__()._annotations['parententity'] in terms of aliased class, test it all.
Diffstat (limited to 'test/orm/test_utils.py')
-rw-r--r--test/orm/test_utils.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/orm/test_utils.py b/test/orm/test_utils.py
index ae225ad92..168cee19c 100644
--- a/test/orm/test_utils.py
+++ b/test/orm/test_utils.py
@@ -222,6 +222,56 @@ class AliasedClassTest(fixtures.TestBase, AssertsCompiledSQL):
"WHERE point_1.x > point.x"
)
+ def test_parententity_vs_parentmapper(self):
+ class Point(object):
+ pass
+
+ self._fixture(Point, properties={
+ 'x_syn': synonym("x")
+ })
+ pa = aliased(Point)
+
+ is_(Point.x_syn._parententity, inspect(Point))
+ is_(Point.x._parententity, inspect(Point))
+ is_(Point.x_syn._parentmapper, inspect(Point))
+ is_(Point.x._parentmapper, inspect(Point))
+
+ is_(
+ Point.x_syn.__clause_element__()._annotations['parententity'],
+ inspect(Point))
+ is_(
+ Point.x.__clause_element__()._annotations['parententity'],
+ inspect(Point))
+ is_(
+ Point.x_syn.__clause_element__()._annotations['parentmapper'],
+ inspect(Point))
+ is_(
+ Point.x.__clause_element__()._annotations['parentmapper'],
+ inspect(Point))
+
+ pa = aliased(Point)
+
+ is_(pa.x_syn._parententity, inspect(pa))
+ is_(pa.x._parententity, inspect(pa))
+ is_(pa.x_syn._parentmapper, inspect(Point))
+ is_(pa.x._parentmapper, inspect(Point))
+
+ is_(
+ pa.x_syn.__clause_element__()._annotations['parententity'],
+ inspect(pa)
+ )
+ is_(
+ pa.x.__clause_element__()._annotations['parententity'],
+ inspect(pa)
+ )
+ is_(
+ pa.x_syn.__clause_element__()._annotations['parentmapper'],
+ inspect(Point))
+ is_(
+ pa.x.__clause_element__()._annotations['parentmapper'],
+ inspect(Point))
+
+
class IdentityKeyTest(_fixtures.FixtureTest):
run_inserts = None