After checking the docs, I am not exactly sure how to configure (if 
possible) a type such that SA will handle 
the deletes if underlying database does not support CASCADE.  

1.  Is it now expected that all DBs support ondelete="CASCADE" and you are 
expected to use it?
2.  Should ORM relations with cascade="all, delete" also 
passive_deletes=True?


Thanks,
Kris


For example: 

I have some hierarchical types are self-referential and I would like to 
configure ondelete and onupdate.
the following Node class has a root FK so we can delete all elements in a 
single bang by deleting the root node.

node = Table('nodes', metadata=Metadata(), 
                      Column('node_id', Integer, primary_key=True),
                      Column('comment', Text),
                      Column('parent_id', Integer, 
ForeignKey('node.node_id'), ondelete='cascade'),
                      Column('root_id', Integer, 
ForeignKey('node.node_id'),   ondelete='cascade' )

mapper( Node, node,
                       properties = {
 
    'children' : relation(Node, lazy=True, cascade="all, delete-orphan", 
 passive_deletes=True,
                          backref = backref('parent', 
enable_typechecks=False, remote_side = [ node.c.node_id]),
                          primaryjoin = (node.c.node_id == 
node.c.parent_id)),
    'allnodes': relation(Taggable, lazy=True, 
                         cascade = "all, delete-orphan", 
passive_delete=True,
                         post_update=True,
                         primaryjoin = (node.c.node_id == 
taggable.c.root_id),
                         backref = backref('document', post_update=True, 
                                           , remote_side=[node.c.node_id]),
                         ),

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/Z8uQkJsClgsJ.
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.

Reply via email to