mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Refactor update_all statements in order to prevent deprecation warnings in Rails 4
This commit is contained in:
@@ -30,7 +30,7 @@ class PostDestroyer
|
||||
|
||||
# If the poster doesn't have any other posts in the topic, clear their posted flag
|
||||
unless Post.exists?(["topic_id = ? and user_id = ? and id <> ?", @post.topic_id, @post.user_id, @post.id])
|
||||
TopicUser.update_all 'posted = false', topic_id: @post.topic_id, user_id: @post.user_id
|
||||
TopicUser.where(topic_id: @post.topic_id, user_id: @post.user_id).update_all 'posted = false'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ class PostDestroyer
|
||||
@post.post_actions.map(&:trash!)
|
||||
|
||||
f = PostActionType.types.map{|k,v| ["#{k}_count", 0]}
|
||||
Post.with_deleted.update_all(Hash[*f.flatten], id: @post.id)
|
||||
Post.with_deleted.where(id: @post.id).update_all(Hash[*f.flatten])
|
||||
|
||||
@post.trash!
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ class SiteSettings::DbProvider
|
||||
|
||||
return unless table_exists?
|
||||
|
||||
count = @model.update_all({
|
||||
count = @model.where({
|
||||
name: name
|
||||
}).update_all({
|
||||
name: name,
|
||||
value: value,
|
||||
data_type: data_type,
|
||||
updated_at: Time.now
|
||||
}, {
|
||||
name: name
|
||||
})
|
||||
|
||||
if count == 0
|
||||
|
||||
@@ -39,7 +39,7 @@ module Trashable
|
||||
#
|
||||
# Fixed in Rails 4
|
||||
#
|
||||
self.class.unscoped.update_all({deleted_at: nil}, id: self.id)
|
||||
self.class.unscoped.where(id: self.id).update_all({deleted_at: nil})
|
||||
raw_write_attribute :deleted_at, nil
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user