Method: ActiveRecord::ConnectionAdapters::Mysql2::DatabaseStatements#internal_exec_query

Defined in:
activerecord/lib/active_record/connection_adapters/mysql2/database_statements.rb

#internal_exec_query(sql, name = "SQL", binds = [], prepare: false, async: false, allow_retry: false) ⇒ Object

:nodoc:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'activerecord/lib/active_record/connection_adapters/mysql2/database_statements.rb', line 16

def internal_exec_query(sql, name = "SQL", binds = [], prepare: false, async: false, allow_retry: false) # :nodoc:
  if without_prepared_statement?(binds)
    execute_and_free(sql, name, async: async, allow_retry: allow_retry) do |result|
      if result
        build_result(columns: result.fields, rows: result.to_a)
      else
        build_result(columns: [], rows: [])
      end
    end
  else
    exec_stmt_and_free(sql, name, binds, cache_stmt: prepare, async: async) do |_, result|
      if result
        build_result(columns: result.fields, rows: result.to_a)
      else
        build_result(columns: [], rows: [])
      end
    end
  end
end