Sha256: 4bfe4f2c190ac3babfced0ce6cb3ee3aa2a3fe5e6e6d697e3dd7b42443838ecf

Contents?: true

Size: 750 Bytes

Versions: 246

Compression:

Stored size: 750 Bytes

Contents

# frozen_string_literal: true

module Motor
  module Queries
    module PostgresqlExecQuery
      module_function

      def call(conn, statement)
        conn.send(:execute_and_clear, *statement) do |result|
          types = {}
          fields = result.fields

          fields.each_with_index do |fname, i|
            ftype = result.ftype i
            fmod  = result.fmod i
            types[fname] = conn.send(:get_oid_type, ftype, fmod, fname)
          end

          if conn.respond_to?(:build_result, true)
            conn.send(:build_result, columns: fields, rows: result.values, column_types: types)
          else
            ActiveRecord::Result.new(fields, result.values, types)
          end
        end
      end
    end
  end
end

Version data entries

246 entries across 246 versions & 7 rubygems

Version Path
motor-admin-0.4.32 lib/motor/queries/postgresql_exec_query.rb
motor-admin-0.4.31 lib/motor/queries/postgresql_exec_query.rb
motor-admin-0.4.30 lib/motor/queries/postgresql_exec_query.rb
motor-admin-0.4.29 lib/motor/queries/postgresql_exec_query.rb
motor-admin-0.4.28 lib/motor/queries/postgresql_exec_query.rb
motor-admin-cstham8-0.4.35 lib/motor/queries/postgresql_exec_query.rb
motor-admin-cstham8-0.4.34 lib/motor/queries/postgresql_exec_query.rb
motor-admin-cstham8-0.4.33 lib/motor/queries/postgresql_exec_query.rb
motor-admin-cstham8-0.4.32 lib/motor/queries/postgresql_exec_query.rb
motor-admin-cstham8-0.4.31 lib/motor/queries/postgresql_exec_query.rb
motor-admin-cstham8-0.4.30 lib/motor/queries/postgresql_exec_query.rb
motor-admin-cstham8-0.4.29 lib/motor/queries/postgresql_exec_query.rb
motor-admin-cstham8-0.4.28 lib/motor/queries/postgresql_exec_query.rb
motor-admin-cstham8-0.4.27 lib/motor/queries/postgresql_exec_query.rb
motor-admin-0.4.27 lib/motor/queries/postgresql_exec_query.rb
motor-admin-unosquare-0.4.28 lib/motor/queries/postgresql_exec_query.rb
motor-admin-unosquare-0.4.27 lib/motor/queries/postgresql_exec_query.rb
motor-admin-pz-0.4.26 lib/motor/queries/postgresql_exec_query.rb
motor-admin-0.4.26 lib/motor/queries/postgresql_exec_query.rb
motor-admin-0.4.25 lib/motor/queries/postgresql_exec_query.rb