Module Sequel::Postgres::PGRange::DatabaseMethods
In: lib/sequel/extensions/pg_range.rb

Methods

Public Class methods

Define a private range typecasting method for the given type that uses the parser argument to do the type conversion.

[Source]

     # File lib/sequel/extensions/pg_range.rb, line 211
211:         def self.define_range_typecast_method(type, parser)
212:           meth = "typecast_value_#{type}""typecast_value_#{type}"
213:           define_method(meth){|v| typecast_value_pg_range(v, parser)}
214:           private meth
215:         end

Reset the conversion procs if using the native postgres adapter, and extend the datasets to correctly literalize ruby Range values.

[Source]

     # File lib/sequel/extensions/pg_range.rb, line 190
190:         def self.extended(db)
191:           db.instance_eval do
192:             extend_datasets(DatasetMethods)
193:             copy_conversion_procs([3904, 3906, 3912, 3926, 3905, 3907, 3913, 3927])
194:             [:int4range, :numrange, :tsrange, :tstzrange, :daterange, :int8range].each do |v|
195:               @schema_type_classes[v] = PGRange
196:             end
197:           end
198: 
199:           procs = db.conversion_procs
200:           procs[3908] = Parser.new("tsrange", procs[1114])
201:           procs[3910] = Parser.new("tstzrange", procs[1184])
202:           if defined?(PGArray::Creator)
203:             procs[3909] = PGArray::Creator.new("tsrange", procs[3908])
204:             procs[3911] = PGArray::Creator.new("tstzrange", procs[3910])
205:           end
206: 
207:         end

Public Instance methods

Handle Range and PGRange values in bound variables

[Source]

     # File lib/sequel/extensions/pg_range.rb, line 218
218:         def bound_variable_arg(arg, conn)
219:           case arg
220:           when PGRange 
221:             arg.unquoted_literal(schema_utility_dataset)
222:           when Range
223:             PGRange.from_range(arg).unquoted_literal(schema_utility_dataset)
224:           else
225:             super
226:           end
227:         end

[Validate]