Rails4: replace deprecated Relation#update_all at Issue model

git-svn-id: http://svn.redmine.org/redmine/trunk@12532 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2014-01-08 12:20:52 +00:00
parent 84f43584f9
commit 8aa22a05f4
1 changed files with 3 additions and 3 deletions

View File

@ -1222,7 +1222,7 @@ class Issue < ActiveRecord::Base
def after_project_change def after_project_change
# Update project_id on related time entries # Update project_id on related time entries
TimeEntry.update_all(["project_id = ?", project_id], {:issue_id => id}) TimeEntry.where({:issue_id => id}).update_all(["project_id = ?", project_id])
# Delete issue relations # Delete issue relations
unless Setting.cross_project_issue_relations? unless Setting.cross_project_issue_relations?
@ -1313,8 +1313,8 @@ class Issue < ActiveRecord::Base
self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id ) self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id )
target_maxright = nested_set_scope.maximum(right_column_name) || 0 target_maxright = nested_set_scope.maximum(right_column_name) || 0
offset = target_maxright + 1 - lft offset = target_maxright + 1 - lft
Issue.update_all(["root_id = ?, lft = lft + ?, rgt = rgt + ?", root_id, offset, offset], Issue.where(["root_id = ? AND lft >= ? AND rgt <= ? ", old_root_id, lft, rgt]).
["root_id = ? AND lft >= ? AND rgt <= ? ", old_root_id, lft, rgt]) update_all(["root_id = ?, lft = lft + ?, rgt = rgt + ?", root_id, offset, offset])
self[left_column_name] = lft + offset self[left_column_name] = lft + offset
self[right_column_name] = rgt + offset self[right_column_name] = rgt + offset
if @parent_issue if @parent_issue