method
exec_query
v5.0.0.1 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::SQLite3Adapter
exec_query(sql, name = nil, binds = [], prepare: false)public
No documentation available.
# File activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb, line 190
def exec_query(sql, name = nil, binds = [], prepare: false)
type_casted_binds = binds.map { |attr| type_cast(attr.value_for_database) }
log(sql, name, binds) do
# Don't cache statements if they are not prepared
unless prepare
stmt = @connection.prepare(sql)
begin
cols = stmt.columns
unless without_prepared_statement?(binds)
stmt.bind_params(type_casted_binds)
end
records = stmt.to_a
ensure
stmt.close
end
stmt = records
else
cache = @statements[sql] ||= {
:stmt => @connection.prepare(sql)
}
stmt = cache[:stmt]
cols = cache[:cols] ||= stmt.columns
stmt.reset!
stmt.bind_params(type_casted_binds)
end
ActiveRecord::Result.new(cols, stmt.to_a)
end
end