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