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
242 def parse
243   values = []
244   skip(/\(/)
245   if skip(/\)/)
246     values << nil
247   else
248     # :nocov:
249     until eos?
250     # :nocov:
251       if skip(/"/)
252         values << scan(/(\\.|""|[^"])*/).gsub(/\\(.)|"(")/, '\1\2')
253         skip(/"[,)]/)
254       else
255         v = scan(/[^,)]*/)
256         values << (v unless v.empty?)
257         skip(/[,)]/)
258       end
259     end
260   end
261   values
262 end