##// END OF EJS Templates
Use r13844 workaround for SQLServer only....
Jean-Philippe Lang -
r13463:dcda9977e376
parent child
Show More
@@ -149,12 +149,17 module Redmine
149 end
149 end
150
150
151 def lock_nested_set
151 def lock_nested_set
152 lock = true
153 if self.class.connection.adapter_name =~ /sqlserver/i
152 if self.class.connection.adapter_name =~ /sqlserver/i
154 lock = "WITH (ROWLOCK HOLDLOCK UPDLOCK)"
153 lock = "WITH (ROWLOCK HOLDLOCK UPDLOCK)"
154 # Custom lock for SQLServer
155 # This can be problematic if root_id or parent root_id changes
156 # before locking
157 sets_to_lock = [root_id, parent.try(:root_id)].compact.uniq
158 self.class.reorder(:id).where(:root_id => sets_to_lock).lock(lock).ids
159 else
160 sets_to_lock = [id, parent_id].compact
161 self.class.reorder(:id).where("root_id IN (SELECT root_id FROM #{self.class.table_name} WHERE id IN (?))", sets_to_lock).lock.ids
155 end
162 end
156 sets_to_lock = [root_id, parent.try(:root_id)].compact.uniq
157 self.class.reorder(:id).where(:root_id => sets_to_lock).lock(lock).ids
158 end
163 end
159
164
160 def nested_set_scope
165 def nested_set_scope
General Comments 0
You need to be logged in to leave comments. Login now