diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-07 21:11:05 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-07 21:11:05 +0000 |
commit | dcda9977e376b383191fe1f5a963bc28a5dd84ee (patch) | |
tree | 6da7a9330b173a335562606ef19aca6fc5bb0288 | |
parent | a7378e450d25a82394f80d219fb17f3d343230ea (diff) | |
download | redmine-dcda9977e376b383191fe1f5a963bc28a5dd84ee.tar.gz redmine-dcda9977e376b383191fe1f5a963bc28a5dd84ee.zip |
Use r13844 workaround for SQLServer only.
git-svn-id: http://svn.redmine.org/redmine/trunk@13845 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | lib/redmine/nested_set/issue_nested_set.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/redmine/nested_set/issue_nested_set.rb b/lib/redmine/nested_set/issue_nested_set.rb index 9d525293f..eadc71161 100644 --- a/lib/redmine/nested_set/issue_nested_set.rb +++ b/lib/redmine/nested_set/issue_nested_set.rb @@ -149,12 +149,17 @@ module Redmine end def lock_nested_set - lock = true if self.class.connection.adapter_name =~ /sqlserver/i lock = "WITH (ROWLOCK HOLDLOCK UPDLOCK)" + # 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 + 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 - sets_to_lock = [root_id, parent.try(:root_id)].compact.uniq - self.class.reorder(:id).where(:root_id => sets_to_lock).lock(lock).ids end def nested_set_scope |