SA is not actively tracking primary/foreign key attributes on instances. it will translate the way your objects are connected together into database relationships upon a flush() and thats about it. if youre manipulating foreign key attributes, SA is fine with that but youre essentially tinkering below the level of the ORM, so it assumes youre going to handle the details.
On Jul 21, 2006, at 2:25 AM, non-alex wrote: > Hi! > > > My question is about automatic updating (__in memory__, not db) > one_to_many relationships before flushing the session. Is that > possible? > > Trivial example: > > master_table = Table('master', metadata, > Column('master_id', Integer, primary_key = True), > ┘. > ) > > detail_table = Table('detail', metadata, > Column('detail_id', Integer, primary_key = True), > ┘ > Column('master_id', Integer, ForeignKey("master.master_id")) > > Objects and mappers are: > > class Master(object): > pass > Class Detail(object): > pass > > detail_mapper=mapper(Detail,detail_table) > detail_mapper.add_property('master_ref', relation(Master)) > > I get detail object and set detail.master_id to another value. > After change of detail.master_id we have: > detail.master_id<>detail.master_ref.master_id. > > Can SA automatically switch detail.master_ref to the > correct Master object? > > Thanks in advance, alex. > > ---------------------------------------------------------------------- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys -- and earn > cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Sqlalchemy-users mailing list > Sqlalchemy-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users