class Sequel::Postgres::PGMultiRange
:nocov:
Attributes
db_type[RW]
The type of this multirange (e.g. ‘int4multirange’).
Public Class Methods
new(ranges, db_type)
click to toggle source
Set the array of ranges to delegate to, and the database type.
Calls superclass method
# File lib/sequel/extensions/pg_multirange.rb 276 def initialize(ranges, db_type) 277 super(ranges) 278 @db_type = db_type.to_s 279 end
Public Instance Methods
==(other)
click to toggle source
Don’t consider multiranges with different database types equal.
Calls superclass method
# File lib/sequel/extensions/pg_multirange.rb 319 def ==(other) 320 return false if PGMultiRange === other && other.db_type != db_type 321 super 322 end
cover?(value)
click to toggle source
Return whether the value is inside any of the ranges in the multirange.
# File lib/sequel/extensions/pg_multirange.rb 304 def cover?(value) 305 any?{|range| range.cover?(value)} 306 end
Also aliased as: ===
eql?(other)
click to toggle source
Don’t consider multiranges with different database types equal.
# File lib/sequel/extensions/pg_multirange.rb 310 def eql?(other) 311 if PGMultiRange === other 312 return false unless other.db_type == db_type 313 other = other.__getobj__ 314 end 315 __getobj__.eql?(other) 316 end
op()
click to toggle source
sql_literal_append(ds, sql)
click to toggle source
Append the multirange SQL
to the given sql string.
# File lib/sequel/extensions/pg_multirange.rb 282 def sql_literal_append(ds, sql) 283 sql << db_type << '(' 284 joiner = nil 285 conversion_meth = nil 286 each do |range| 287 if joiner 288 sql << joiner 289 else 290 joiner = ', ' 291 end 292 293 unless range.is_a?(PGRange) 294 conversion_meth ||= :"typecast_value_#{db_type.sub('multi', '')}" 295 range = ds.db.send(conversion_meth, range) 296 end 297 298 ds.literal_append(sql, range) 299 end 300 sql << ')' 301 end
unquoted_literal(ds)
click to toggle source
Return a string containing the unescaped version of the multirange. Separated out for use by the bound argument code.
# File lib/sequel/extensions/pg_multirange.rb 326 def unquoted_literal(ds) 327 val = String.new 328 val << "{" 329 330 joiner = nil 331 conversion_meth = nil 332 each do |range| 333 if joiner 334 val << joiner 335 else 336 joiner = ', ' 337 end 338 339 unless range.is_a?(PGRange) 340 conversion_meth ||= :"typecast_value_#{db_type.sub('multi', '')}" 341 range = ds.db.send(conversion_meth, range) 342 end 343 344 val << range.unquoted_literal(ds) 345 end 346 347 val << "}" 348 end