instance method
exec_query
Ruby on Rails 6.0.6
Since v6.0.6 Last seen in v6.1.7.10Available in: v6.0.6 v6.1.7.10
Signature
exec_query(sql, name = nil, binds = [], prepare: false)
No documentation comment.
Parameters
-
sqlreq -
nameopt = nil -
bindsopt = [] -
preparekey = false
Source
# File activerecord/lib/active_record/connection_adapters/sqlite3/database_statements.rb, line 30
def exec_query(sql, name = nil, binds = [], prepare: false)
if preventing_writes? && write_query?(sql)
raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
end
materialize_transactions
type_casted_binds = type_casted_binds(binds)
log(sql, name, binds, type_casted_binds) do
ActiveSupport::Dependencies.interlock.permit_concurrent_loads 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
else
stmt = @statements[sql] ||= @connection.prepare(sql)
cols = stmt.columns
stmt.reset!
stmt.bind_params(type_casted_binds)
records = stmt.to_a
end
ActiveRecord::Result.new(cols, records)
end
end
end
Defined in activerecord/lib/active_record/connection_adapters/sqlite3/database_statements.rb line 30
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::SQLite3::DatabaseStatements