Thanks, Mike. The docs look like they are a little out of date on this. For delete-orphan, they say that "Note that this option prevents a pending item of the child’s class from being persisted without a parent present." http://www.sqlalchemy.org/docs/orm/relationships.html#relationships-api
On Tue, Nov 1, 2011 at 11:00 AM, Michael Bayer <[email protected]>wrote: > > On Nov 1, 2011, at 6:48 AM, Michael Naber wrote: > > > Quick question: Why am I allowed to persist an address with no > person_id? Shouldn't the delete-orphan prohibit this? > > This was the behavior up until 0.7, when the decision was reversed - > delete-orphan now considers an "orphan" to be only an object that *had* a > parent, now does not. To prevent the insertion of a row that has no > parent to start with you'd use a NOT NULL constraint on the foreign key. > > The improvement here allows delete-orphan cascade to be used on > hierarchical structures where the "root" row has no parent. No > functionality is lost for systems where parents are required as that's what > constraints are for. > > Notes: > http://www.sqlalchemy.org/trac/wiki/07Migration#Flushingoforphansthathavenoparentisallowed > > -- > 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. > > -- 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.
