Class Sequel::Postgres::PGNumericArray
In: lib/sequel/extensions/pg_array.rb
Parent: PGArray

PGArray subclass handling integer and float types, using a fast JSON parser. Does not handle numeric/decimal types, since JSON does deal with arbitrary precision (see PGDecimalArray for that).

Methods

parse  

Constants

SUBST = {'{'.freeze=>'['.freeze, '}'.freeze=>']'.freeze, 'NULL'.freeze=>'null'.freeze}   Character conversion map mapping input strings to JSON replacements
SUBST_RE = %r[\{|\}|NULL].freeze   Regular expression matching input strings to convert

Public Class methods

Parse the input string by using a gsub to convert non-JSON characters to JSON, running it through a regular JSON parser, and the doing a recursive map over the output to make sure the entries are in the correct type (mostly, to make sure real/double precision database types are returned as float and not integer).

[Source]

     # File lib/sequel/extensions/pg_array.rb, line 349
349:       def self.parse(string, type=nil)
350:         new(recursive_map(JSON.parse(string.gsub(SUBST_RE){|m| SUBST[m]})), type)
351:       end

[Validate]