class Sequel::Postgres::PGRow::Splitter

  1. lib/sequel/extensions/pg_row.rb
Superclass: StringScanner

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.

Methods

Public Instance

  1. parse

Public Instance methods

parse()

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

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