Method: MultiInsert::Query#execute
- Defined in:
- lib/multi_insert/query.rb
#execute ⇒ nil | Array<Integer> | Array<Array<String | Number | Boolean>>
Execute the query, and return eventual results.
Result may be:
-
Nil if no returning clause was present.
-
An array of IDs if the returning_id helper was called.
-
An array of rows otherwise.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/multi_insert/query.rb', line 122 def execute result = nil ActiveRecord::Base.connection_pool.with_connection do |con| result = con.execute(to_sql) end if @sql_returning.nil? nil else if @returning_flat result.values.map{|r| r.first} else result end end end |