mirror of
https://github.com/redmine/redmine.git
synced 2025-10-30 01:36:04 +01:00
Use r13844 workaround for SQLServer only.
git-svn-id: http://svn.redmine.org/redmine/trunk@13845 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -149,12 +149,17 @@ module Redmine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def lock_nested_set
|
def lock_nested_set
|
||||||
lock = true
|
|
||||||
if self.class.connection.adapter_name =~ /sqlserver/i
|
if self.class.connection.adapter_name =~ /sqlserver/i
|
||||||
lock = "WITH (ROWLOCK HOLDLOCK UPDLOCK)"
|
lock = "WITH (ROWLOCK HOLDLOCK UPDLOCK)"
|
||||||
end
|
# Custom lock for SQLServer
|
||||||
|
# This can be problematic if root_id or parent root_id changes
|
||||||
|
# before locking
|
||||||
sets_to_lock = [root_id, parent.try(:root_id)].compact.uniq
|
sets_to_lock = [root_id, parent.try(:root_id)].compact.uniq
|
||||||
self.class.reorder(:id).where(:root_id => sets_to_lock).lock(lock).ids
|
self.class.reorder(:id).where(:root_id => sets_to_lock).lock(lock).ids
|
||||||
|
else
|
||||||
|
sets_to_lock = [id, parent_id].compact
|
||||||
|
self.class.reorder(:id).where("root_id IN (SELECT root_id FROM #{self.class.table_name} WHERE id IN (?))", sets_to_lock).lock.ids
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def nested_set_scope
|
def nested_set_scope
|
||||||
|
|||||||
Reference in New Issue
Block a user