Adds methods that allow you to treat an object as an instance of a specific
ComplexExpression
subclass.
Extract a datetime part (e.g. year, month) from self:
Sequel[:date].extract(:year) # extract(year FROM "date")
Also has the benefit of returning the result as a NumericExpression instead of a generic ComplexExpression.
# File lib/sequel/sql.rb, line 704 def extract(datetime_part) NumericExpression.new(:extract, datetime_part, self) end
Return a BooleanExpression
representation of self
.
# File lib/sequel/sql.rb, line 709 def sql_boolean BooleanExpression.new(:NOOP, self) end
Return a NumericExpression
representation of self
.
~Sequel[:a] # NOT "a" ~(Sequel[:a].sql_number) # ~"a"
# File lib/sequel/sql.rb, line 717 def sql_number NumericExpression.new(:NOOP, self) end
Return a StringExpression
representation of self
.
Sequel[:a] + :b # "a" + "b" Sequel[:a].sql_string + :b # "a" || "b"
# File lib/sequel/sql.rb, line 725 def sql_string StringExpression.new(:NOOP, self) end