module Sequel::SQL::ComplexExpressionMethods

  1. lib/sequel/sql.rb

Adds methods that allow you to treat an object as an instance of a specific ComplexExpression subclass.

Methods

Public Instance

  1. extract
  2. sql_boolean
  3. sql_number
  4. sql_string

Public Instance methods

extract(datetime_part)

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.

[show source]
    # File lib/sequel/sql.rb
729 def extract(datetime_part)
730   NumericExpression.new(:extract, datetime_part, self)
731 end
sql_boolean()

Return a BooleanExpression representation of self.

[show source]
    # File lib/sequel/sql.rb
734 def sql_boolean
735   BooleanExpression.new(:NOOP, self)
736 end
sql_number()

Return a NumericExpression representation of self.

~Sequel[:a] # NOT "a"
~(Sequel[:a].sql_number) # ~"a"
[show source]
    # File lib/sequel/sql.rb
742 def sql_number
743   NumericExpression.new(:NOOP, self)
744 end
sql_string()

Return a StringExpression representation of self.

Sequel[:a] + :b # "a" + "b"
Sequel[:a].sql_string + :b # "a" || "b"
[show source]
    # File lib/sequel/sql.rb
750 def sql_string
751   StringExpression.new(:NOOP, self)
752 end