- Fixed bug where Query would crash if a join() with no clear
"left" side were called when a non-mapped column entity
appeared in the columns list. [ticket:1602]
+
+ - 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.
- sql
- Fixed bug in two-phase transaction whereby commit() method
cond = sql.and_(*allconds)
- return sql.select([props[key].columns[0] for key in attribute_names], cond, use_labels=True)
+ cols = []
+ for key in attribute_names:
+ cols.extend(props[key].columns)
+ return sql.select(cols, cond, use_labels=True)
def cascade_iterator(self, type_, state, halt_on=None):
"""Iterate each element and its mapper in an object graph,
@classmethod
def define_tables(cls, metadata):
- global base, sub
+ global base, sub, with_comp
base = Table('base', metadata,
Column('id', Integer, primary_key=True),
Column('data', String(50)),
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
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):