jack.pref = newpref
jack.pref = newpref
sess.flush()
- eq_(sess.query(Pref).all(),
+ eq_(sess.query(Pref).order_by(Pref.id).all(),
[Pref(data="pref 1"), Pref(data="pref 3"), Pref(data="newpref")])
class M2OCascadeDeleteTest(_base.MappedTest):
"""A server-side default can be used as the target of a foreign key"""
mapper(Hoho, default_t, properties={
- 'secondaries':relation(Secondary)})
+ 'secondaries':relation(Secondary, order_by=secondary_table.c.id)})
mapper(Secondary, secondary_table)
h1 = Hoho()
t2 = Table('t2', m,
Column('a', Integer, ForeignKey('t.a', use_alter=True, name='fk_ta')),
+ Column('b', Integer, ForeignKey('t.a', name='fk_tb')), # to ensure create ordering ...
)
e = engines.mock_engine(dialect_name='postgres')
m.drop_all(e)
e.assert_sql([
- "CREATE TABLE t (a INTEGER)",
- "CREATE TABLE t2 (a INTEGER)",
- "ALTER TABLE t2 ADD CONSTRAINT fk_ta FOREIGN KEY(a) REFERENCES t (a)",
- "ALTER TABLE t2 DROP CONSTRAINT fk_ta",
- "DROP TABLE t2",
- "DROP TABLE t",
+ 'CREATE TABLE t (a INTEGER)',
+ 'CREATE TABLE t2 (a INTEGER, b INTEGER, CONSTRAINT fk_tb FOREIGN KEY(b) REFERENCES t (a))',
+ 'ALTER TABLE t2 ADD CONSTRAINT fk_ta FOREIGN KEY(a) REFERENCES t (a)',
+ 'ALTER TABLE t2 DROP CONSTRAINT fk_ta',
+ 'DROP TABLE t2',
+ 'DROP TABLE t'
])