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.


Public Instance

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

Public Instance methods


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
726 def extract(datetime_part)
727, datetime_part, self)
728 end

Return a BooleanExpression representation of self.

[show source]
    # File lib/sequel/sql.rb
731 def sql_boolean
732, self)
733 end

Return a NumericExpression representation of self.

~Sequel[:a] # NOT "a"
~(Sequel[:a].sql_number) # ~"a"
[show source]
    # File lib/sequel/sql.rb
739 def sql_number
740, self)
741 end

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
747 def sql_string
748, self)
749 end