Module: Sequel::Postgres::PGRange::DatabaseMethods
- Defined in:
- lib/sequel/extensions/pg_range.rb
Class Method Summary collapse
-
.define_range_typecast_method(type, parser) ⇒ Object
Define a private range typecasting method for the given type that uses the parser argument to do the type conversion.
-
.extended(db) ⇒ Object
Reset the conversion procs if using the native postgres adapter, and extend the datasets to correctly literalize ruby Range values.
Instance Method Summary collapse
-
#bound_variable_arg(arg, conn) ⇒ Object
Handle Range and PGRange values in bound variables.
Class Method Details
.define_range_typecast_method(type, parser) ⇒ Object
Define a private range typecasting method for the given type that uses the parser argument to do the type conversion.
211 212 213 214 215 |
# File 'lib/sequel/extensions/pg_range.rb', line 211 def self.define_range_typecast_method(type, parser) meth = :"typecast_value_#{type}" define_method(meth){|v| typecast_value_pg_range(v, parser)} private meth end |
.extended(db) ⇒ Object
Reset the conversion procs if using the native postgres adapter, and extend the datasets to correctly literalize ruby Range values.
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/sequel/extensions/pg_range.rb', line 190 def self.extended(db) db.instance_eval do extend_datasets(DatasetMethods) copy_conversion_procs([3904, 3906, 3912, 3926, 3905, 3907, 3913, 3927]) [:int4range, :numrange, :tsrange, :tstzrange, :daterange, :int8range].each do |v| @schema_type_classes[v] = PGRange end end procs = db.conversion_procs procs[3908] = Parser.new("tsrange", procs[1114]) procs[3910] = Parser.new("tstzrange", procs[1184]) if defined?(PGArray::Creator) procs[3909] = PGArray::Creator.new("tsrange", procs[3908]) procs[3911] = PGArray::Creator.new("tstzrange", procs[3910]) end end |
Instance Method Details
#bound_variable_arg(arg, conn) ⇒ Object
Handle Range and PGRange values in bound variables
218 219 220 221 222 223 224 225 226 227 |
# File 'lib/sequel/extensions/pg_range.rb', line 218 def bound_variable_arg(arg, conn) case arg when PGRange arg.unquoted_literal(schema_utility_dataset) when Range PGRange.from_range(arg).unquoted_literal(schema_utility_dataset) else super end end |