Sha256: a651f4c242a9e26060b2c1cfe673230899184ff880f74b9d9b0777d7a3a54531

Contents?: true

Size: 858 Bytes

Versions: 4

Compression:

Stored size: 858 Bytes

Contents

require_relative "jdbc"
require_relative "postgresql"

class Upsert
  class Connection
    # @private
    class Java_OrgPostgresqlJdbc_PgConnection < Connection
      include Jdbc
      include Postgresql

      def quote_ident(k)
        DOUBLE_QUOTE + k.to_s.gsub(DOUBLE_QUOTE, '""') + DOUBLE_QUOTE
      end

      def in_transaction?
        # https://github.com/kares/activerecord-jdbc-adapter/commit/4d6e0e0c52d12b0166810dffc9f898141a23bee6
        ![0, 4].include?(metal.get_transaction_state)
      end

      def bind_value(v)
        case v
        when DateTime, Time
          date = v.utc
          java.time.LocalDateTime.of(date.year, date.month, date.day, date.hour, date.min, date.sec, date.nsec)
        when Date
          java.time.LocalDate.of(v.year, v.month, v.day)
        else
          super
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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