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