From 4e5cd5fb0fac047237c5b0fd9ef2b937d41db6b2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 15 Sep 2011 16:23:15 -0400 Subject: [PATCH] - Fixed previously untested function which regressed in 0.7, can now make a synonym() of a synonym() again. --- CHANGES | 4 ++++ lib/sqlalchemy/orm/descriptor_props.py | 2 ++ test/orm/test_mapper.py | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/CHANGES b/CHANGES index 99af9e4a3e..f98071715a 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,10 @@ CHANGES when the Session.is_active is True. [ticket:2241] + - Fixed previously untested function which regressed + in 0.7, can now make a synonym() of a synonym() + again. + - Identity map .discard() uses dict.pop(,None) internally instead of "del" to avoid KeyError/warning during a non-determinate gc teardown [ticket:2267] diff --git a/lib/sqlalchemy/orm/descriptor_props.py b/lib/sqlalchemy/orm/descriptor_props.py index f43952279a..6385d40e29 100644 --- a/lib/sqlalchemy/orm/descriptor_props.py +++ b/lib/sqlalchemy/orm/descriptor_props.py @@ -360,6 +360,8 @@ class SynonymProperty(DescriptorProperty): if self.comparator_factory: comp = self.comparator_factory(prop, mapper) + elif isinstance(prop, DescriptorProperty): + comp = prop._comparator_factory(mapper) else: comp = prop.comparator_factory(prop, mapper) return comp diff --git a/test/orm/test_mapper.py b/test/orm/test_mapper.py index 90ad2d2158..306ca56a77 100644 --- a/test/orm/test_mapper.py +++ b/test/orm/test_mapper.py @@ -1074,6 +1074,20 @@ class MapperTest(_fixtures.FixtureTest): eq_(User.uname.attribute, 123) eq_(User.uname['key'], 'value') + def test_synonym_of_synonym(self): + users, User = (self.tables.users, + self.classes.User) + + mapper(User, users, properties={ + 'x':synonym('id'), + 'y':synonym('x') + }) + + s = Session() + u = s.query(User).filter(User.y==8).one() + eq_(u.y, 8) + + def test_synonym_column_location(self): users, User = self.tables.users, self.classes.User -- 2.47.3