mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 03:10:46 -06:00
make it more idiomatic
This commit is contained in:
parent
5f8851cb44
commit
a3128665cf
@ -12,17 +12,9 @@ class ActiveRecord::Base
|
||||
end
|
||||
|
||||
# note: update_attributes still spins up a transaction this can cause contention
|
||||
# this method performs the raw update sidestepping AR
|
||||
# this method performs the raw update sidestepping the locking
|
||||
def update_columns(hash)
|
||||
sql = "UPDATE #{ self.class.table_name } SET "
|
||||
|
||||
sql << hash.map do |k,v|
|
||||
"#{k} = :#{k}"
|
||||
end.join(",")
|
||||
|
||||
sql << " WHERE id = :id"
|
||||
|
||||
exec_sql(sql, hash.merge(id: self.id))
|
||||
self.class.update_all(hash, self.class.primary_key => self.id)
|
||||
end
|
||||
|
||||
def exec_sql(*args)
|
||||
|
Loading…
Reference in New Issue
Block a user