On 12 Feb., 18:17, "Luke Stebbing" <[EMAIL PROTECTED]> wrote:
> Right, "delete-orphan" is what adds the lifecycle relationship between
> parent and child. It means that the child can't exist without a
> parent. That lets SA know that it should eliminate the child rather
> than trying to null out the relationship.
The misunderstanding is obviously the question "which one is the
child, which is the parent".
The ORM , as far as I understand, does never care for the table
structure. Particularly, it plays no role which table has the Foreign
Key.
Therefore, I expected the following declaration
mapper(Userdata, t_userdata, properties = {
"myuser":relation(User,backref=backref("meta",cascade="delete"))
})
to define a cascade where User.delete triggers a Userdata.delete.
(I expected this because the "cascade" keyword is in the "backref",
not in the "relation" !)
But now it seems to me that it doesn't matter where I define the
cascade. I tested some cases and obviously the rule is the following:
The fist object that defines a property "relation", becomes the
parent.
Subsequent "backref", and even subsequent
addProperty(foo:relation ...) on the child play no role anymore.
It this right ? Btw, can I find this rule ("who is the Parent")
somewhere in the API docs ?
Ruben
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---