summaryrefslogtreecommitdiff
path: root/test/orm/inheritance/test_basic.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-11-15 20:39:39 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-11-15 20:39:39 +0000
commit734dce8b60320791efc85005f6a9dde116ff8898 (patch)
tree3506f0def8e639501c4aa12b399d1c70cdfccbc2 /test/orm/inheritance/test_basic.py
parent943ce6bf16e27dd21c0c463e52988edf58d691bb (diff)
downloadsqlalchemy-734dce8b60320791efc85005f6a9dde116ff8898.tar.gz
- Fixed bug whereby composite columns wouldn't load properly
when configured on a joined-table subclass, introduced in version 0.5.6 as a result of the fix for [ticket:1480]. [ticket:1616] thx to Scott Torborg.
Diffstat (limited to 'test/orm/inheritance/test_basic.py')
-rw-r--r--test/orm/inheritance/test_basic.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py
index a682d38cb..b02db4e1b 100644
--- a/test/orm/inheritance/test_basic.py
+++ b/test/orm/inheritance/test_basic.py
@@ -1021,7 +1021,7 @@ class OptimizedLoadTest(_base.MappedTest):
@classmethod
def define_tables(cls, metadata):
- global base, sub
+ global base, sub, with_comp
base = Table('base', metadata,
Column('id', Integer, primary_key=True, test_needs_autoincrement=True),
Column('data', String(50)),
@@ -1031,6 +1031,11 @@ class OptimizedLoadTest(_base.MappedTest):
Column('id', Integer, ForeignKey('base.id'), primary_key=True),
Column('sub', String(50))
)
+ with_comp = Table('with_comp', metadata,
+ Column('id', Integer, ForeignKey('base.id'), primary_key=True),
+ Column('a', String(10)),
+ Column('b', String(10))
+ )
def test_optimized_passes(self):
""""test that the 'optimized load' routine doesn't crash when
@@ -1104,6 +1109,35 @@ class OptimizedLoadTest(_base.MappedTest):
Sub(data='s3data', sub='s3sub', concat='s3data|s3sub')
]
)
+
+ def test_composite_column_joined(self):
+ class Base(_base.ComparableEntity):
+ pass
+ class WithComp(Base):
+ pass
+ class Comp(object):
+ def __init__(self, a, b):
+ self.a = a
+ self.b = b
+ def __composite_values__(self):
+ return self.a, self.b
+ def __eq__(self, other):
+ return (self.a == other.a) and (self.b == other.b)
+ mapper(Base, base, polymorphic_on=base.c.type, polymorphic_identity='base')
+ mapper(WithComp, with_comp, inherits=Base, polymorphic_identity='wc', properties={
+ 'comp': composite(Comp, with_comp.c.a, with_comp.c.b)
+ })
+ sess = sessionmaker()()
+ s1 = WithComp(data='s1data', comp=Comp('ham', 'cheese'))
+ s2 = WithComp(data='s2data', comp=Comp('bacon', 'eggs'))
+ sess.add_all([s1, s2])
+ sess.commit()
+ sess.expunge_all()
+ s1test, s2test = sess.query(Base).order_by(Base.id).all()
+ assert s1test.comp
+ assert s2test.comp
+ eq_(s1test.comp, Comp('ham', 'cheese'))
+ eq_(s2test.comp, Comp('bacon', 'eggs'))
class PKDiscriminatorTest(_base.MappedTest):