Methods
Public Instance
Public Instance methods
Return a DateAdd expression, adding an interval to the date/timestamp expr.
# File lib/sequel/extensions/date_arithmetic.rb, line 31 def date_add(expr, interval) DateAdd.new(expr, interval) end
Return a DateAdd expression, adding the negative of the interval to the date/timestamp expr.
# File lib/sequel/extensions/date_arithmetic.rb, line 37 def date_sub(expr, interval) interval = if interval.is_a?(Hash) h = {} interval.each{|k,v| h[k] = -v unless v.nil?} h else -interval end DateAdd.new(expr, interval) end
Return a Postgres::HStore proxy for the given hash.
# File lib/sequel/extensions/pg_hstore.rb, line 316 def hstore(v) case v when Postgres::HStore v when Hash Postgres::HStore.new(v) else # May not be defined unless the pg_hstore_ops extension is used hstore_op(v) end end
Return the object wrapped in an Postgres::HStoreOp.
# File lib/sequel/extensions/pg_hstore_ops.rb, line 308 def hstore_op(v) case v when Postgres::HStoreOp v else Postgres::HStoreOp.new(v) end end
Return a Postgres::PGArray proxy for the given array and database array type.
# File lib/sequel/extensions/pg_array.rb, line 581 def pg_array(v, array_type=nil) case v when Postgres::PGArray if array_type.nil? || v.array_type == array_type v else Postgres::PGArray.new(v.to_a, array_type) end when Array Postgres::PGArray.new(v, array_type) else # May not be defined unless the pg_array_ops extension is used pg_array_op(v) end end
Return the object wrapped in an Postgres::ArrayOp.
# File lib/sequel/extensions/pg_array_ops.rb, line 275 def pg_array_op(v) case v when Postgres::ArrayOp v else Postgres::ArrayOp.new(v) end end
Wrap the array or hash in a Postgres::JSONArray or Postgres::JSONHash.
# File lib/sequel/extensions/pg_json.rb, line 195 def pg_json(v) case v when Postgres::JSONArray, Postgres::JSONHash v when Array Postgres::JSONArray.new(v) when Hash Postgres::JSONHash.new(v) else Sequel.pg_json_op(v) end end
Return the object wrapped in an Postgres::JSONOp.
# File lib/sequel/extensions/pg_json_ops.rb, line 227 def pg_json_op(v) case v when Postgres::JSONOp v else Postgres::JSONOp.new(v) end end
Convert the object to a Postgres::PGRange.
# File lib/sequel/extensions/pg_range.rb, line 501 def pg_range(v, db_type=nil) case v when Postgres::PGRange if db_type.nil? || v.db_type == db_type v else Postgres::PGRange.new(v.begin, v.end, :exclude_begin=>v.exclude_begin?, :exclude_end=>v.exclude_end?, :db_type=>db_type) end when Range Postgres::PGRange.from_range(v, db_type) else # May not be defined unless the pg_range_ops extension is used pg_range_op(v) end end
Return the expression wrapped in the Postgres::RangeOp.
# File lib/sequel/extensions/pg_range_ops.rb, line 128 def pg_range_op(v) case v when Postgres::RangeOp v else Postgres::RangeOp.new(v) end end
Wraps the expr array in an anonymous Postgres::PGRow::ArrayRow instance.
# File lib/sequel/extensions/pg_row.rb, line 578 def pg_row(expr) case expr when Array Postgres::PGRow::ArrayRow.new(expr) else # Will only work if pg_row_ops extension is loaded pg_row_op(expr) end end
Return a PGRowOp wrapping the given expression.
# File lib/sequel/extensions/pg_row_ops.rb, line 165 def pg_row_op(expr) Postgres::PGRowOp.wrap(expr) end