@@ -97,7 +97,7 @@ def create_many(rows, options = {})
9797 end
9898 end
9999 column_values = column_names . map do |column_name |
100- quote_value ( row [ column_name ] , columns_hash [ column_name . to_s ] )
100+ bulk_methods_quote_value ( columns_hash [ column_name . to_s ] , row [ column_name ] )
101101 end . join ( ',' )
102102 "(#{ column_values } )"
103103 end . each_slice ( options [ :slice_size ] ) do |insert_slice |
@@ -226,9 +226,9 @@ def update_many(rows, options = {})
226226 column_name = column_name . to_s
227227 columns_hash_value = columns_hash [ column_name ]
228228 if i == 0
229- "#{ quote_value ( column_value , columns_hash_value ) } ::#{ columns_hash_value . sql_type } as #{ column_name } "
229+ "#{ bulk_methods_quote_value ( columns_hash_value , column_value ) } ::#{ columns_hash_value . sql_type } as #{ column_name } "
230230 else
231- quote_value ( column_value , columns_hash_value )
231+ bulk_methods_quote_value ( columns_hash_value , column_value )
232232 end
233233 end . join ( ',' )
234234 end
@@ -251,4 +251,12 @@ def update_many(rows, options = {})
251251 end
252252 return returning
253253 end
254+
255+ def bulk_methods_quote_value ( postgre_sql_column , column_value )
256+ if Rails . version >= '5.0.0'
257+ connection . quote connection . type_cast_from_column ( postgre_sql_column , column_value )
258+ else
259+ quote_value ( column_value , postgre_sql_column )
260+ end
261+ end
254262end
0 commit comments