Simplify values_sql_for_column_names_and_attributes with #map
This commit is contained in:
parent
7aefcf1164
commit
6b2153a841
|
@ -119,16 +119,12 @@ module ActiveRecord::Import::AbstractAdapter
|
||||||
# Returns SQL the VALUES for an INSERT statement given the passed in +columns+
|
# Returns SQL the VALUES for an INSERT statement given the passed in +columns+
|
||||||
# and +array_of_attributes+.
|
# and +array_of_attributes+.
|
||||||
def values_sql_for_column_names_and_attributes( columns, array_of_attributes ) # :nodoc:
|
def values_sql_for_column_names_and_attributes( columns, array_of_attributes ) # :nodoc:
|
||||||
values = []
|
array_of_attributes.map do |arr|
|
||||||
array_of_attributes.each do |arr|
|
my_values = arr.each_with_index.map do |val,j|
|
||||||
my_values = []
|
quote( columns[j].type_cast(val), columns[j] )
|
||||||
arr.each_with_index do |val,j|
|
|
||||||
importable_value = columns[j].type_cast(val)
|
|
||||||
my_values << quote(importable_value, columns[j] )
|
|
||||||
end
|
end
|
||||||
values << my_values
|
"(#{my_values.join(',')})"
|
||||||
end
|
end
|
||||||
values_arr = values.map{ |arr| '(' + arr.join( ',' ) + ')' }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the maximum number of bytes that the server will allow
|
# Returns the maximum number of bytes that the server will allow
|
||||||
|
|
Loading…
Reference in a new issue