Sha256: 84c5acc98eb3fefca635c5c4ba6d42f55df1b0968b6b7650147624706ebe9cfa

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 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
            vv.gsub! /\\/, '\&\&'
            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

1 entries across 1 versions & 1 rubygems

Version Path
upsert-2.0.0 lib/upsert/connection/postgresql.rb