server-side defaults needed for relations can't fire off within flush()

Issue #954 resolved
Mike Bayer repo owner created an issue
default_table = Table('default_test', metadata,
    Column('id', Integer, Sequence("dt_seq", optional=True), primary_key=True),
    Column('hoho', hohotype, PassiveDefault(str(hohoval))),
)

secondary_table = Table('secondary_table', metadata, 
    Column('id', Integer, primary_key=True),
    Column('hoho', hohotype, ForeignKey('default_test.hoho')), # foreign key to a passive default
    Column('data', String(50))
    )

class Hoho(fixtures.Base):
    pass
class Secondary(fixtures.Base):
    pass

mapper(Hoho, default_table, properties={
    'secondaries':relation(Secondary)
})

mapper(Secondary, secondary_table)
h1 = Hoho()
s1 = Secondary(data='s1')
h1.secondaries.append(s1)
Session.commit()
Session.clear()

self.assertEquals(Session.query(Hoho).get(h1.id), Hoho(hoho=hohoval, secondaries=[hoho=hohoval)](Secondary(data='s1',)))

Comments (2)

  1. Log in to comment