Class Index [+]

Quicksearch

Sequel::Postgres::PGArray::DatabaseMethods

Constants

ESCAPE_RE
ESCAPE_REPLACEMENT

Public Class Methods

extended(db) click to toggle source

Reset the conversion procs when extending the Database object, so it will pick up the array convertors. This is only done for the native postgres adapter.

     # File lib/sequel/extensions/pg_array.rb, line 103
103:         def self.extended(db)
104:           db.reset_conversion_procs if db.respond_to?(:reset_conversion_procs)
105:         end

Public Instance Methods

bound_variable_arg(arg, conn) click to toggle source

Handle arrays in bound variables

     # File lib/sequel/extensions/pg_array.rb, line 108
108:         def bound_variable_arg(arg, conn)
109:           case arg
110:           when PGArray
111:             bound_variable_array(arg.to_a)
112:           when Array
113:             bound_variable_array(arg)
114:           else
115:             super
116:           end
117:         end
schema_column_type(db_type) click to toggle source

Make the column type detection deal with string and numeric array types.

     # File lib/sequel/extensions/pg_array.rb, line 120
120:         def schema_column_type(db_type)
121:           case db_type
122:           when /\A(character( varying)?|text).*\[\]\z/o
123:             :string_array
124:           when /\A(integer|bigint|smallint)\[\]\z/o
125:             :integer_array
126:           when /\A(real|double precision)\[\]\z/o
127:             :float_array
128:           when /\Anumeric.*\[\]\z/o
129:             :decimal_array
130:           else
131:             super
132:           end
133:         end

Private Instance Methods

bound_variable_array(a) click to toggle source

Format arrays used in bound variables.

     # File lib/sequel/extensions/pg_array.rb, line 138
138:         def bound_variable_array(a)
139:           case a
140:           when Array
141:             "{#{a.map{|i| bound_variable_array(i)}.join(COMMA)}}"
142:           when String
143:             "\"#{a.gsub(ESCAPE_RE, ESCAPE_REPLACEMENT)}\""
144:           else
145:             literal(a)
146:           end
147:         end
typecast_value_pg_array(value, klass) click to toggle source

Given a value to typecast and the type of PGArray subclass:

  • If given a PGArray, just return the value (even if different subclass)

  • If given an Array, create a new instance of the subclass

  • If given a String, call the parser for the subclass with it.

     # File lib/sequel/extensions/pg_array.rb, line 153
153:         def typecast_value_pg_array(value, klass)
154:           case value
155:           when PGArray
156:             value
157:           when Array
158:             klass.new(value)
159:           when String
160:             klass.parse(value)
161:           else
162:             raise Sequel::InvalidValue, "invalid value for #{klass}: #{value.inspect}"
163:           end
164:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.