Method: ActiveRecord::Import::AbstractAdapter::InstanceMethods#insert_many

Defined in:
lib/activerecord-import/adapters/abstract_adapter.rb

#insert_many(sql, values, _options = {}, *args) ⇒ Object

:nodoc:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/activerecord-import/adapters/abstract_adapter.rb', line 9

def insert_many( sql, values, _options = {}, *args ) # :nodoc:
  number_of_inserts = 1

  base_sql, post_sql = case sql
                       when String
                         [sql, '']
                       when Array
                         [sql.shift, sql.join( ' ' )]
  end

  sql2insert = base_sql + values.join( ',' ) + post_sql
  insert( sql2insert, *args )

  ActiveRecord::Import::Result.new([], number_of_inserts, [], [])
end