Method: ActiveRecord::ConnectionAdapters::PostgreSQL::DatabaseStatements#query

Defined in:
lib/active_record/connection_adapters/postgresql/database_statements.rb

#query(sql, name = nil) ⇒ Object

Queries the database and returns the results in an Array-like object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/active_record/connection_adapters/postgresql/database_statements.rb', line 14

def query(sql, name = nil) # :nodoc:
  mark_transaction_written_if_write(sql)

  log(sql, name) do |notification_payload|
    with_raw_connection do |conn|
      result = conn.async_exec(sql).map_types!(@type_map_for_results).values
      verified!
      notification_payload[:row_count] = result.count
      result
    end
  end
end