Sha256: 68eb27dc77785ddf648fa5465f024e866e30f60aa7011ebf2a27d08163c6168a

Contents?: true

Size: 682 Bytes

Versions: 9

Compression:

Stored size: 682 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.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

9 entries across 9 versions & 1 rubygems

Version Path
upsert-2.2.1 lib/upsert/connection/postgresql.rb
upsert-2.2.0 lib/upsert/connection/postgresql.rb
upsert-2.1.2 lib/upsert/connection/postgresql.rb
upsert-2.1.1 lib/upsert/connection/postgresql.rb
upsert-2.1.0 lib/upsert/connection/postgresql.rb
upsert-2.0.4 lib/upsert/connection/postgresql.rb
upsert-2.0.3 lib/upsert/connection/postgresql.rb
upsert-2.0.2 lib/upsert/connection/postgresql.rb
upsert-2.0.1 lib/upsert/connection/postgresql.rb