summaryrefslogtreecommitdiff
path: root/test/orm/test_mapper.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-03-09 13:24:54 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-03-09 13:24:54 -0500
commit852e9954aaec7205e7ebaf3d0b232e1e8ff20e63 (patch)
treeeda5a78cc0f9a496c4b662885a4b5810669d6dc6 /test/orm/test_mapper.py
parentd2a256a3ad48341e013b6e7a3e911495e5b5d31a (diff)
downloadsqlalchemy-852e9954aaec7205e7ebaf3d0b232e1e8ff20e63.tar.gz
A meaningful :attr:`.QueryableAttribute.info` attribute is
added, which proxies down to the ``.info`` attribute on either the :class:`.schema.Column` object if directly present, or the :class:`.MapperProperty` otherwise. The full behavior is documented and ensured by tests to remain stable. [ticket:2675]
Diffstat (limited to 'test/orm/test_mapper.py')
-rw-r--r--test/orm/test_mapper.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/orm/test_mapper.py b/test/orm/test_mapper.py
index 66082b549..6b97fb135 100644
--- a/test/orm/test_mapper.py
+++ b/test/orm/test_mapper.py
@@ -407,6 +407,37 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL):
obj.info["q"] = "p"
eq_(obj.info, {"q": "p"})
+ def test_info_via_instrumented(self):
+ m = MetaData()
+ # create specific tables here as we don't want
+ # users.c.id.info to be pre-initialized
+ users = Table('u', m, Column('id', Integer, primary_key=True),
+ Column('name', String))
+ addresses = Table('a', m, Column('id', Integer, primary_key=True),
+ Column('name', String),
+ Column('user_id', Integer, ForeignKey('u.id')))
+ Address = self.classes.Address
+ User = self.classes.User
+
+ mapper(User, users, properties={
+ "name_lower": column_property(func.lower(users.c.name)),
+ "addresses": relationship(Address)
+ })
+ mapper(Address, addresses)
+
+ # attr.info goes down to the original Column object
+ # for the dictionary. The annotated element needs to pass
+ # this on.
+ assert 'info' not in users.c.id.__dict__
+ is_(User.id.info, users.c.id.info)
+ assert 'info' in users.c.id.__dict__
+
+ # for SQL expressions, ORM-level .info
+ is_(User.name_lower.info, User.name_lower.property.info)
+
+ # same for relationships
+ is_(User.addresses.info, User.addresses.property.info)
+
def test_add_property(self):
users, addresses, Address = (self.tables.users,