lib/upsert/connection/postgresql.rb in upsert-1.2.0 vs lib/upsert/connection/postgresql.rb in upsert-2.0.0
- old
+ new
@@ -2,9 +2,18 @@
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