Methods

Class Index [+]

Quicksearch

Sequel::SQL::NumericMethods

This module includes the standard mathematical methods (+, -, *, and /) that are defined on objects that can be used in a numeric context in SQL (Symbol, LiteralString, and +SQL::GenericExpression+).

  :a + :b # "a" + "b"
  :a - :b # "a" - "b"
  :a * :b # "a" * "b"
  :a / :b # "a" / "b"

One exception to this is if + is called with a String or StringExpression, in which case the || operator is used instead of the + operator:

  :a + 'b' # "a" || 'b'

Public Instance Methods

+(ce) click to toggle source

Use || as the operator when called with StringExpression and String instances, and the + operator for LiteralStrings and all other types.

     # File lib/sequel/sql.rb, line 698
698:       def +(ce)
699:         case ce
700:         when LiteralString
701:           NumericExpression.new(:+, self, ce)
702:         when StringExpression, String
703:           StringExpression.new(:'||', self, ce)
704:         else
705:           NumericExpression.new(:+, self, ce)
706:         end
707:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.