-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
This probably should be added to the FAQ.
On 27 Aug 2008, at 00:24, Alex Mathieu wrote:
> Maybe I put my cascade argument at the wrong place
I suspect that may be the case (unless you are using SQLite or MyISM
tables).
Try taking the declaration out of SectionElement.publication and put
it into PublicationElement.sections:
class PublicationElement(Entity):
using_options(tablename='publication')
sections = OneToMany('SectionElement', cascade="all,delete-orphan")
[ ... ]
class SectionElement(Entity):
using_options(tablename='section')
publication = ManyToOne('PublicationElement',
colname="publication_id")
[ ... ]
(you may wish to cascade PublicationElement->covers as well)
See the recent sqlelixir posting from Jul 29 by Jason Coombes:
http://groups.google.com/group/sqlelixir/msg/b2d530d53b1f28ff
copied here for completeness:
> If [ ... ] you want Elixir/SQLAlchemy to handle the
> cascading deletes, you need to put this definition in the OneToMany
> declaration in the parent class:
> class Director(Entity):
> movies = OneToMany('Movie', cascade='all, delete-orphan')
>
If you want the database to handle the cascades, Jason recommends
"including ondelete="cascade" in your metadata when you create the
database will add that rule to the database definition" but I can't
find a specific reference in either the Elixir docs or the SA docs as
to exactly how to do that.
In case it is relevant to your instance: in the relevant section in
the SA docs Mike Bayer warns that neither SQLite nor MySQL's MyISAM
table type support cascade deletions:
http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_largecollections_passivedelete
For a more detailed understanding of cascade deletions, this blog post
might help:
http://blog.pythonisito.com/2008/07/cascade-rules-in-sqlalchemy.html
Sorry I can't be more definite.
Cheers,
Graham
-----BEGIN PGP SIGNATURE-----
iEYEARECAAYFAki0qcMACgkQOsmLt1NhivwOhQCeLowH7WXeUBg6PMCUR6RRCIw0
Si0AoN3mK7ZsniTXC58Mf/9bahj7aAmdiQCVAgUBSLSpw1nrWVZ7aXD1AQJqDQQA
0jiv+XbNQwZNhNV4BXsG9xMTdj8rSQ3Nb0rpxgoIiZgXtUg1rvFj5kgNdBmPqUCf
9zV+p54JaRtOY7cOYaQJExrrCQqXgug47DT2/YGXfiPInj8McsZH0nZ7FHr8oQNv
axU+fBbuN/OpjLrS+S1gXQBPngC/uuJHPZO1o+V3sfo=
=2zON
-----END PGP SIGNATURE-----
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---