Class: Sequel::Postgres::PGRow::Splitter
- Defined in:
- lib/sequel/extensions/pg_row.rb
Overview
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.
Instance Method Summary collapse
-
#parse ⇒ Object
Split the stored string into an array of strings, handling the different types of quoting.
Instance Method Details
#parse ⇒ Object
Split the stored string into an array of strings, handling the different types of quoting.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/sequel/extensions/pg_row.rb', line 224 def parse values = [] skip(/\(/) if skip(/\)/) values << nil else # :nocov: until eos? # :nocov: if skip(/"/) values << scan(/(\\.|""|[^"])*/).gsub(/\\(.)|"(")/, '\1\2') skip(/"[,)]/) else v = scan(/[^,)]*/) values << (v unless v.empty?) skip(/[,)]/) end end end values end |