In fact, I think I figured it out how it was working... but I still
get this error:

<class 'sqlalchemy.exceptions.AssertionError'>: Dependency rule tried
to blank-out primary key column 'default_sections.section_id' on
instance '[EMAIL PROTECTED]'

It appears that it tries to set my foregin key in my child element to
zero, instead of deleting it (and now SA is complaining because that
foreign key is the primary key of the table).

Any idea on why it tries to put the key to 0 instead of deleting the
whole child object ?

On Aug 26, 6:08 pm, Alex Mathieu <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm using Elixir & SQLAlchemy to manage some entities, it's going
> quite well. However, I just realize that when I was deleting my
> parents entities, my sons entites were not deleted. The're might be
> something I didn't get quite well, so that's why I'm requiring some
> help...
>
> Let's say I have two classes:
>
> class PublicationElement(Entity):
>     using_options(tablename='publication')
>     sections = OneToMany('SectionElement')
>     covers = OneToMany('PublicationCoverElement')
>     publication_id = Field(Integer, primary_key=True)
>     name = Field(Unicode(255))
>     short_name = Field(Unicode(30))
>     app_download_link = Field(UnicodeText)
>
> class SectionElement(Entity):
>     using_options(tablename='section')
>     publication = ManyToOne('PublicationElement',
> colname="publication_id", cascade="all,delete-orphan")
>     section_id = Field(Integer, primary_key=True)
>     name = Field(Unicode(255))
>     articles_on_cover = Field(Integer)
>     articles_on_sub_cover = Field(Integer)
>     ad_on_top = Field(Boolean)
>     ad_on_bottom = Field(Boolean)
>     poll_rate_minutes = Field(Integer)
>     poll_weight = Field(Integer)
>     show_sub_cover = Field(Boolean)
>
> If I delete a PublicationElement entity, all the related
> SectionElement entities get their publication_id key set to 0... and I
> just can't figure it out why. I've been digging through the web, but
> wasn't able any answer... Maybe I putted my cascade argument at the
> wrong place ? Not sure to get it...
>
> Thanks in advance,
>
> A.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to