[Sorry for reposting, Erroneously sent to another thread.]
In faq 5.13 it's explained why setting bar.foo_id would not generate the object bar.foo. I stumble in the same problem when creating a Movie in an example with Director/Movie and a relation -'movies' on director- that has 'delete-orphan'. running:: f = m.Movie(title="my title") f.director_id = 1 sess.commit() Would issue an error: Instance <Movie at 0xb7dab72c> is an unsaved, pending instance and is an orphan (is not attached to any parent 'Director' instance via that classes' 'movies' attribute) the reason is explained in the faq, no Director instance has been created. The problem is that I can't use the proposed solution of expiring the session since the object is not yet persisted (Instance '<Movie at 0xb7d8564c>' is not persistent within this Session). Wouldn't be this a situation when an automatic loading would be possible? or at least would it be possible to trap the error as the error really only should enforce that no orpahn is left, but the foreign key (if existent) ensures that already. thanks sandro *:-) ----------------------------------- class Director(Base): __tablename__ = 'director' id = Column(Integer, primary_key=True) name = Column(String(60)) movies = relation('Movie', backref='director', cascade='all, delete-orphan',) class Movie(Base): __tablename__ = 'movie' id = Column(Integer, primary_key=True) title = Column(String(60), nullable=False) director_id = Column(Integer, ForeignKey('director.id'), nullable=False) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---