# File lib/dbd/pg/type.rb, line 55 def self.parse(obj) return nil if obj.nil? # FIXME there's a bug in the upstream 'pg' driver that does not # properly decode bytea, leaving in an extra slash for each decoded # character. # # Fix this for now, but beware that we'll have to unfix this as # soon as they fix their end. ret = PGconn.unescape_bytea(obj) # XXX # String#split does not properly create a full array if the the # string ENDS in the split regex, unless this oddball -1 argument is supplied. # # Another way of saying this: # if foo = "foo\\\\\" and foo.split(/\\\\/), the result will be # ["foo"]. You can add as many delimiters to the end of the string # as you'd like - the result is no different. # ret = ret.split(/\\\\/, -1).collect { |x| x.length > 0 ? x.gsub(/\\[0-7]{3}/) { |y| y[1..3].oct.chr } : "" }.join("\\") ret.gsub!(/''/, "'") return ret end