module Sequel::SQL::OperatorBuilders

  1. lib/sequel/sql.rb

This adds methods to create SQL expressions using operators:

Sequel.+(1, :a)   # (1 + a)
Sequel.-(1, :a)   # (1 - a)
Sequel.*(1, :a)   # (1 * a)
Sequel./(1, :a)   # (1 / a)
Sequel.&(:b, :a)   # (b AND a)
Sequel.|(:b, :a)   # (b OR a)

Methods

Public Instance

  1. **
  2. ~

Public Instance methods

**(a, b)

Return NumericExpression for the exponentiation:

Sequel.**(2, 3) # SQL: power(2, 3)
[show source]
    # File lib/sequel/sql.rb
874 def **(a, b)
875   SQL::NumericExpression.new(:**, a, b)
876 end
~(arg)

Invert the given expression. Returns a Sequel::SQL::BooleanExpression created from this argument, not matching all of the conditions.

Sequel.~(nil) # SQL: NOT NULL
Sequel.~([[:a, true]]) # SQL: a IS NOT TRUE
Sequel.~([[:a, 1], [:b, [2, 3]]]) # SQL: a != 1 OR b NOT IN (2, 3)
[show source]
    # File lib/sequel/sql.rb
884 def ~(arg)
885   if condition_specifier?(arg)
886     SQL::BooleanExpression.from_value_pairs(arg, :OR, true)
887   else
888     SQL::BooleanExpression.invert(arg)
889   end
890 end