Sha256: 1de7c469447c970596dd63d5a3d797401d7398b3cd4eeae8c7e36170caf8578f

Contents?: true

Size: 653 Bytes

Versions: 4

Compression:

Stored size: 653 Bytes

Contents

class Upsert
  class Connection
    # @private
    module Postgresql
      def bind_value(v)
        case v
        when Array
          # pg array escaping lifted from https://github.com/tlconnor/activerecord-postgres-array/blob/master/lib/activerecord-postgres-array/array.rb
          '{' + v.map do |vv|
            vv = vv.to_s.dup
            vv.gsub!(/\\/, '\&\&')
            vv.gsub!(/"/, '\"')
            %{"#{vv}"}
          end.join(',') + '}'
        when Hash
          # you must require 'pg_hstore' from the 'pg-hstore' gem yourself
          ::PgHstore.dump v, true
        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/postgresql.rb
upsert-2.9.10 lib/upsert/connection/postgresql.rb
upsert-2.9.9-universal-java-11 lib/upsert/connection/postgresql.rb
upsert-2.9.9 lib/upsert/connection/postgresql.rb