Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sqlalchemy-bot opened this issue Jan 28, 2008 · 2 comments
Closed
Labels
bug Something isn't working high priority orm
Milestone

Comments

@sqlalchemy-bot
Copy link
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)

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',)))
@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

da7fef9

@sqlalchemy-bot
Copy link
Collaborator Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added high priority bug Something isn't working orm labels Nov 27, 2018
@sqlalchemy-bot sqlalchemy-bot added this to the 0.4.3 milestone Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority orm
Projects
None yet
Development

No branches or pull requests

1 participant