Class Sequel::Postgres::PGRow::Splitter
In: lib/sequel/extensions/pg_row.rb
Parent: 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

parse  

Public Instance methods

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

[Source]

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

[Validate]