python - SQLAlchemy before_update called instead after_delete -


Can someone tell me what I am doing?

I have a way with which Register event (before_update, after_delete, before_insert)

  @classmethod DEF register_tree (CLS): event.listen (cls, "before_insert", cls.mptt_before_insert event.listen (cls, "after_delete", cls.mptt_after_delete) event.listen (cls, "before_update", cls.mptt_before_update)   

When I registered the event and the row () Attempt to delete class tree (base, baseNestedSets): __tablename__ = "tree" id = column (integer, primary_key = true) tree.register_tree () def test_delete_node (Self): node = self.session.query (tree) .filter (Tree.id == 4) .one () self.session.delete (node) # id lft rgt lvl parent tree self.assertEqual ([( 1, 1, 16, 1, none, 1), (2, 2, 5, 2, 1, 1), (3, 3, 4, 3, 2, 1), (7, 6, 15, 2 , 1, 1), (8, 7, 10, 3, 7, 1), (9, 8, 9, 4, 8, 1), (10, 11, 14, 3, 7, 1) 12, 13, 4, 10, 1)], self. Retail.All ())

The first _dated method is called instead after_delete. But if I before_update event comment () this job is ok

  @classmethod DEF register_tree (CLS):. Event.listen (CLS, "before_insert", cls.mptt_before_insert) event.listen (CLS, "after_delete", cls.mptt_after_delete) # event.listen (CLS, "before_update", cls.mptt_before_update) & lt; - If this comment is called, after_delete method, this is called. This is right.      P> Resolve it  

It has been found that when you remove the node with children, then update before Scalailmi Set the children (original parent_id = none) and then delete the node. When I set the cascade = "all, delete", then this node will remove one from one (w / o update).

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -