mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 14:49:07 +08:00
backport fix for rails
This commit is contained in:
parent
216ecaaffd
commit
edf6f3012d
22
lib/freedom_patches/join_dependency.rb
Normal file
22
lib/freedom_patches/join_dependency.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# see PR: https://github.com/rails/rails/pull/12185
|
||||
#
|
||||
class ActiveRecord::Associations::JoinDependency::JoinPart
|
||||
|
||||
def extract_record(row)
|
||||
# Used to be: Hash[column_names_with_alias.map{|cn, an| [cn, row[an]]}]
|
||||
# that is fairly inefficient cause all the values are first copied
|
||||
# in to an array only to construct the Hash
|
||||
# This code is performance critical as it is called per row.
|
||||
hash = {}
|
||||
|
||||
index = 0
|
||||
while index < column_names_with_alias.length do
|
||||
cn,an = column_names_with_alias[index]
|
||||
hash[cn] = row[an]
|
||||
index += 1
|
||||
end
|
||||
|
||||
hash
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user