Trying to find out if I hit a bug or it is me doing something wrong.
Using version 0.4.6
when creating an object and then calling session.save() I get:
Instance 'res...@-0x486e4074' is already persistent
It works save_or_update() with, but I don't see why I should use that.
I did read that using session.mapper can cause this but I use
orm.mapper.
Here is the mapping code:
metadata = sa.MetaData()
sm = orm.sessionmaker(autoflush=True, transactional=True,
bind=engine)
Model.session = orm.scoped_session(sm)
person_table = sa.Table('person', metadata, autoload = True,
autoload_with=engine)
person_relative_table = sa.Table('person_relative', metadata,
autoload = True, autoload_with=engine)
resume_table = sa.Table('resume', metadata, autoload = True,
autoload_with=engine)
workplace_table = sa.Table('workplace', metadata, autoload =
True, autoload_with=engine)
resume_workplace_table = sa.Table('resume_workplace',
metadata, autoload = True, autoload_with=engine)
orm.mapper(self.Person, person_table, properties = {
'relatives' : orm.relation(self.Person,
secondary=person_relative_table,
primaryjoin=person_table.c.id==person_relative_table.c.person_id,
secondaryjoin=person_relative_table.c.relative_id==person_table.c.id,
backref='followers'),
'resumes' : orm.relation(self.Resume, backref='person')
}
)
orm.mapper(self.Resume, resume_table, properties = {
'workplaces' : orm.relation(self.Workplace,
secondary=resume_workplace_table, backref='resumes')
}
)
orm.mapper(self.Workplace, workplace_table)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---