class Sequel::Postgres::PGRow::Splitter

This parser-like class splits the PostgreSQL row-valued/composite type output string format into an array of strings. Note this class makes no attempt to handle all input formats that PostgreSQL will accept, it only handles the output format that PostgreSQL uses.

Public Instance Methods

parse() click to toggle source

Split the stored string into an array of strings, handling the different types of quoting.

    # File lib/sequel/extensions/pg_row.rb
224 def parse
225   return @result if @result
226   values = []
227   skip(/\(/)
228   if skip(/\)/)
229     values << nil
230   else
231     # :nocov:
232     until eos?
233     # :nocov:
234       if skip(/"/)
235         values << scan(/(\\.|""|[^"])*/).gsub(/\\(.)|"(")/, '\1\2')
236         skip(/"[,)]/)
237       else
238         v = scan(/[^,)]*/)
239         values << (v unless v.empty?)
240         skip(/[,)]/)
241       end
242     end
243   end
244   values
245 end