instance method exec_query

Ruby on Rails 6.1.7.10

Since v4.2.9 Last seen in v6.1.7.10

Available in: v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10

Signature

exec_query(sql, name = "SQL", binds = [], prepare: false)

No documentation comment.

Parameters

sql req
name opt = "SQL"
binds opt = []
prepare key = false
Source
# File activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb, line 54
        def exec_query(sql, name = "SQL", binds = [], prepare: false)
          execute_and_clear(sql, name, binds, prepare: prepare) do |result|
            types = {}
            fields = result.fields
            fields.each_with_index do |fname, i|
              ftype = result.ftype i
              fmod  = result.fmod i
              case type = get_oid_type(ftype, fmod, fname)
              when Type::Integer, Type::Float, OID::Decimal, Type::String, Type::DateTime, Type::Boolean
                # skip if a column has already been type casted by pg decoders
              else types[fname] = type
              end
            end
            build_result(columns: fields, rows: result.values, column_types: types)
          end
        end

Defined in activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb line 54 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::PostgreSQL::DatabaseStatements

Type at least 2 characters to search.

↑↓ navigate · open · esc close