I've been playing around with a simple self-referential table: abs_categories = Table('abs_categories', meta, Column('id',Integer,primary_key=True), Column('link',String(128),nullable=False), Column('name',String(128)), Column('seq',Integer), Column('template',String(128)), Column('parent_id',Integer,ForeignKey('abs_categories.id')), Column('active',Integer) )
and it's mapper: class Category(object): def __repr__(self): return self.name mapper(Category,abs_categories,order_by=abs_categories.c.seq, properties = { 'products': relation(Product), 'children': relation( Category, cascade="all", backref=backref("parent", foreignkey=abs_categories.c.id)) }) When I select a Category object like so: cat = session.query(Category).get(id) And then immediately delete it: session.delete(cat) It deletes the selected category as expected. But if there are children it doesn't cascade delete. When looking at the examples/adjacencytree.py example I notice that it exhibits the same behavior. If all of the child objects have been "loaded", as in the adjacency example they are all loaded when it prints out the tree, then all of the children will be recursively deleted. But if I haven't recursed the tree and loaded all of the children, when I call session.delete(cat) it only deletes the parent node, and not the children, thus creating a bunch of foreign children. Is this a bug or am I supposed to iterate over the tree to load all the children before calling delete? Any ideas? Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---