@@ -53,7 +53,7 @@ def _ct_after_save
53
53
end
54
54
55
55
def _ct_before_destroy
56
- _ct . with_advisory_lock do
56
+ _ct . with_advisory_lock! do
57
57
delete_hierarchy_references
58
58
if _ct . options [ :dependent ] == :nullify
59
59
self . class . find ( self . id ) . children . find_each { |c | c . rebuild! }
@@ -63,7 +63,7 @@ def _ct_before_destroy
63
63
end
64
64
65
65
def rebuild! ( called_by_rebuild = false )
66
- _ct . with_advisory_lock do
66
+ _ct . with_advisory_lock! do
67
67
delete_hierarchy_references unless ( defined? @was_new_record ) && @was_new_record
68
68
hierarchy_class . create! ( :ancestor => self , :descendant => self , :generations => 0 )
69
69
unless root?
@@ -89,7 +89,7 @@ def rebuild!(called_by_rebuild = false)
89
89
end
90
90
91
91
def delete_hierarchy_references
92
- _ct . with_advisory_lock do
92
+ _ct . with_advisory_lock! do
93
93
# The crazy double-wrapped sub-subselect works around MySQL's limitation of subselects on the same table that is being mutated.
94
94
# It shouldn't affect performance of postgresql.
95
95
# See http://dev.mysql.com/doc/refman/5.0/en/subquery-errors.html
@@ -111,7 +111,7 @@ module ClassMethods
111
111
# Rebuilds the hierarchy table based on the parent_id column in the database.
112
112
# Note that the hierarchy table will be truncated.
113
113
def rebuild!
114
- _ct . with_advisory_lock do
114
+ _ct . with_advisory_lock! do
115
115
cleanup!
116
116
roots . find_each { |n | n . send ( :rebuild! ) } # roots just uses the parent_id column, so this is safe.
117
117
end
0 commit comments