Sha256: c01021616bdd0dc6516635ae1372fb6edad6579888a3edd4e3749be6b12b9e18

Contents?: true

Size: 988 Bytes

Versions: 4

Compression:

Stored size: 988 Bytes

Contents

require_relative "postgresql"

class Upsert
  class Connection
    # @private
    class PG_Connection < Connection
      include Postgresql

      def execute(sql, params = nil)
        if params
          # Upsert.logger.debug { %{[upsert] #{sql} with #{params.inspect}} }
          # The following will blow up if you pass a value that cannot be automatically type-casted,
          #   such as passing a string to an integer field.  You'll get an error something along the
          #   lines of: "invalid input syntax for <type>: <value>"
          metal.exec sql, convert_binary(params)
        else
          Upsert.logger.debug { %{[upsert] #{sql}} }
          metal.exec sql
        end
      end

      def quote_ident(k)
        metal.quote_ident k.to_s
      end

      def binary(v)
        { :value => v.value, :format => 1 }
      end

      def in_transaction?
        ![PG::PQTRANS_IDLE, PG::PQTRANS_UNKNOWN].include?(metal.transaction_status)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
upsert-2.9.10-java lib/upsert/connection/PG_Connection.rb
upsert-2.9.10 lib/upsert/connection/PG_Connection.rb
upsert-2.9.9-universal-java-11 lib/upsert/connection/PG_Connection.rb
upsert-2.9.9 lib/upsert/connection/PG_Connection.rb