15 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: problem with backref| From | Sent On | Attachments |
|---|---|---|
| Manlio Perillo | 20 Dec 2006 01:39 | |
| Manlio Perillo | 20 Dec 2006 02:06 | |
| Alan Franzoni | 20 Dec 2006 08:25 | |
| Manlio Perillo | 20 Dec 2006 13:06 | |
| Alan Franzoni | 20 Dec 2006 16:23 | |
| Michael Bayer | 20 Dec 2006 16:49 | |
| Manlio Perillo | 21 Dec 2006 01:56 | |
| Manlio Perillo | 21 Dec 2006 02:00 | |
| Alan Franzoni | 21 Dec 2006 04:48 | |
| Lee McFadden | 21 Dec 2006 05:10 | |
| Michael Bayer | 21 Dec 2006 08:17 | |
| Manlio Perillo | 23 Dec 2006 03:08 | |
| Michael Bayer | 23 Dec 2006 16:32 | |
| Michael Bayer | 23 Dec 2006 18:53 | |
| Manlio Perillo | 24 Dec 2006 02:27 |
| Subject: | [sqlalchemy] Re: problem with backref![]() |
|---|---|
| From: | Michael Bayer (zzz...@gmail.com) |
| Date: | 12/20/2006 04:49:06 PM |
| List: | com.googlegroups.sqlalchemy |
the original mapping essentially expressed this relationship:
A <-- cascade="all, delete-orphan" --> B
in both directions. What that means is, there cannot be an A with no B in the database, and there cannot be a B with no A in the database, i.e. its either A<->B or both will be deleted. its like an oxygen molecule, or something.
what you need to do is decide which of A and B can exist on its own without a parent relationship. since you want to delete rows from B and not A, that would indicate that the mapping should be:
mapper(A, a) mapper( B, b, properties={ 'a': relation( A, backref=backref('b', lazy=False, uselist=False, cascade='all, delete-orphan'), uselist=False ) } )
i.e. the "delete-orphan" cascade is only in the direction from A->B. the cascade from B->A is left at its default value of "save-update", so delete operations dont propigate from B's to A's.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqla...@googlegroups.com
To unsubscribe from this group, send email to
sqla...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---




