Thank you for the suggestion, but that doesn't change anything.  I
still get an UPDATE statement issued that tries to set the FK id to
NULL, which is invalid and causes SQL logic errors.

Suggestions on where I can go from here would be really appreciated.
I am really stuck on this.  All I need to do is shut that off and
things would work fine.

On Sep 29, 3:31 am, "Sok Ann Yap" <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 29, 2008 at 7:01 AM, Randy Syring <[EMAIL PROTECTED]> wrote:
>
> > I have a ManyToOne() relationship defined with both required=True, and
> > ondelete='cascade'.  When deleting a record from the parent table,
> > Elixir is trying to update related records in the child table and set
> > the parent_id = Null, which is invalid since it is a NOT NULL column.
> > If I remove the corresponding field in the parent object, I don't have
> > the problem any more.  Any ideas?
>
> > My object defs:
>
> > class ContentBaseAttributeCategory(Entity):
>
> >    name = Field(Unicode(255), required=True, unique=True, index=True)
> >    display = Field(Unicode(1000))
> >    inactive = Field(Boolean, required=True, server_default=text("0"))
> >    created = Field(DateTime, required=True,
> > default=datetime.datetime.now)
> >    last_edited = Field(DateTime, onupdate=datetime.datetime.now)
> >    ## if uncommented, SQL errors are generated
> >    #attributes = OneToMany('ContentBaseAttribute')
>
> >    using_options(tablename="contentbase_attribute_categories")
>
> > class ContentBaseAttribute(Entity):
>
> >    category = ManyToOne('ContentBaseAttributeCategory',
> > required=True, ondelete='cascade')
> >    name = Field(Unicode(255), required=True)
> >    display = Field(Unicode(1000))
> >    sort_order = Field(Integer, required=True,
> > server_default=text("0"))
> >    inactive = Field(Boolean, required=True, server_default=text("0"))
> >    created = Field(DateTime, required=True,
> > default=datetime.datetime.now)
> >    last_edited = Field(DateTime, onupdate=datetime.datetime.now)
> >    items = ManyToMany('ContentBaseItem',
> > tablename='contentbase_attribute_item_map', ondelete='cascade')
>
> >    using_options(tablename="contentbase_attributes")
>
> >    def get_catname(self):
> >        return self.category.name
>
> >    catname = property(get_catname)
>
> Try adding cascade='all, delete-orphan' to the OneToMany relationship.
> You can read more about this 
> here:http://www.sqlalchemy.org/docs/04/documentation.html#unitofwork_cascades

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to