Rick Morrison wrote:
> On Jan 17, 2008 7:32 PM, jason kirtland <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>
> Rick Morrison wrote:
> > def setProp(self, new_prop, exclusive=True):
> > if exclusive:
> > self.props = [p for p if p.typ != new_prop.typ]
> > self.props.append(new_prop)
> >
> > o = MappedObject()
> > o.setProp(Prop(typ='a', val='b')
> > o.setProp(Prop(typ='b', val='c')
> >
> > MappedObject has a simple relation() for Prop.
> >
> > at flush() time, the prop for (typ='b') is saved, but the one for
> > (typ='a') throws an error on the database insert saying that
> > table.foreignkey is null
>
> You'd need delete-orphan in the cascade for that relation to dispose of
> all of the instances you're discarding.
>
> But it looks like the trunk is still complaining about 'instance <...>
> is an unsaved, pending instance and is an orphan[...]'. I thought that
> condition had been changed to a warning or a no-op somewhere around
> 0.4.0, guess it didn't.
>
> I don't think the discussion about discarding unpersisted collection
> orphans made the hop onto the list (IRC only) - anyone have an opinion?
> I think I'm still in favor of quashing this exception.
>
> two clarifications: in my case the relation cascade is 'all,
> delete-orphan'. But in the case I'm running into, all of the children
> are unpersisted before the flush.
>
> and the exception I get is not a complaint about an orphan, it's a
> database error when SA tries to persist the (typ='a') item, but does not
> populate it's parent id.
I think there must be something more going on here. Assuming that the
truncated list comprehension is supposed to read:
[p for p in self.props if ...],
and delete-orphan is on, then nothing gets nulled when I run the code.
Do Props have more than one non-nullable parent relation?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---