Michael Bayer ha scritto:

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.


Thanks, this works.

The problem was with my original exemple where I create a session without binding it to a connection.



Regards  Manlio Perillo

--~--~---------~--~----~------------~-------~--~----~
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