diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2014-01-08 06:58:33 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2014-01-08 06:58:33 +0000 |
commit | 2b36ff70168a6b73958d8776a8a8b21166b4d573 (patch) | |
tree | ed0765553684a32b4f6d5303ed709f143c25f9a6 /app/models/user.rb | |
parent | ce2e9158a514c084d01524d4d8b3e1276c4a4f76 (diff) | |
download | redmine-2b36ff70168a6b73958d8776a8a8b21166b4d573.tar.gz redmine-2b36ff70168a6b73958d8776a8a8b21166b4d573.zip |
Rails4: replace deprecated Relation#update_all at User model
git-svn-id: http://svn.redmine.org/redmine/trunk@12524 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 74528aa6d..a88aef8dc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -666,23 +666,27 @@ class User < Principal return if self.id.nil? substitute = User.anonymous - Attachment.update_all ['author_id = ?', substitute.id], ['author_id = ?', id] - Comment.update_all ['author_id = ?', substitute.id], ['author_id = ?', id] - Issue.update_all ['author_id = ?', substitute.id], ['author_id = ?', id] - Issue.update_all 'assigned_to_id = NULL', ['assigned_to_id = ?', id] - Journal.update_all ['user_id = ?', substitute.id], ['user_id = ?', id] - JournalDetail.update_all ['old_value = ?', substitute.id.to_s], ["property = 'attr' AND prop_key = 'assigned_to_id' AND old_value = ?", id.to_s] - JournalDetail.update_all ['value = ?', substitute.id.to_s], ["property = 'attr' AND prop_key = 'assigned_to_id' AND value = ?", id.to_s] - Message.update_all ['author_id = ?', substitute.id], ['author_id = ?', id] - News.update_all ['author_id = ?', substitute.id], ['author_id = ?', id] + Attachment.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) + Comment.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) + Issue.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) + Issue.where(['assigned_to_id = ?', id]).update_all('assigned_to_id = NULL') + Journal.where(['user_id = ?', id]).update_all(['user_id = ?', substitute.id]) + JournalDetail. + where(["property = 'attr' AND prop_key = 'assigned_to_id' AND old_value = ?", id.to_s]). + update_all(['old_value = ?', substitute.id.to_s]) + JournalDetail. + where(["property = 'attr' AND prop_key = 'assigned_to_id' AND value = ?", id.to_s]). + update_all(['value = ?', substitute.id.to_s]) + Message.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) + News.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) # Remove private queries and keep public ones ::Query.delete_all ['user_id = ? AND visibility = ?', id, ::Query::VISIBILITY_PRIVATE] ::Query.update_all ['user_id = ?', substitute.id], ['user_id = ?', id] - TimeEntry.update_all ['user_id = ?', substitute.id], ['user_id = ?', id] + TimeEntry.where(['user_id = ?', id]).update_all(['user_id = ?', substitute.id]) Token.delete_all ['user_id = ?', id] Watcher.delete_all ['user_id = ?', id] - WikiContent.update_all ['author_id = ?', substitute.id], ['author_id = ?', id] - WikiContent::Version.update_all ['author_id = ?', substitute.id], ['author_id = ?', id] + WikiContent.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) + WikiContent::Version.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) end # Return password digest |