@@ -53,7 +53,7 @@ def _ct_after_save
5353 end
5454
5555 def _ct_before_destroy
56- _ct . with_advisory_lock do
56+ _ct . with_advisory_lock! do
5757 delete_hierarchy_references
5858 if _ct . options [ :dependent ] == :nullify
5959 self . class . find ( self . id ) . children . find_each { |c | c . rebuild! }
@@ -63,7 +63,7 @@ def _ct_before_destroy
6363 end
6464
6565 def rebuild! ( called_by_rebuild = false )
66- _ct . with_advisory_lock do
66+ _ct . with_advisory_lock! do
6767 delete_hierarchy_references unless ( defined? @was_new_record ) && @was_new_record
6868 hierarchy_class . create! ( :ancestor => self , :descendant => self , :generations => 0 )
6969 unless root?
@@ -89,7 +89,7 @@ def rebuild!(called_by_rebuild = false)
8989 end
9090
9191 def delete_hierarchy_references
92- _ct . with_advisory_lock do
92+ _ct . with_advisory_lock! do
9393 # The crazy double-wrapped sub-subselect works around MySQL's limitation of subselects on the same table that is being mutated.
9494 # It shouldn't affect performance of postgresql.
9595 # See http://dev.mysql.com/doc/refman/5.0/en/subquery-errors.html
@@ -111,7 +111,7 @@ module ClassMethods
111111 # Rebuilds the hierarchy table based on the parent_id column in the database.
112112 # Note that the hierarchy table will be truncated.
113113 def rebuild!
114- _ct . with_advisory_lock do
114+ _ct . with_advisory_lock! do
115115 cleanup!
116116 roots . find_each { |n | n . send ( :rebuild! ) } # roots just uses the parent_id column, so this is safe.
117117 end
0 commit comments