Class: Sequel::SQL::ColumnExpr

Inherits:
Expression show all
Defined in:
lib/sequel_core/sql.rb

Overview

Represents a generic column expression, used for specifying order and aliasing of columns.

Constant Summary

Constants included from ColumnMethods

Sequel::SQL::ColumnMethods::AS, Sequel::SQL::ColumnMethods::ASC, Sequel::SQL::ColumnMethods::DESC

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#lit

Methods included from ColumnMethods

#as, #asc, #cast_as, #desc

Constructor Details

#initialize(l, op, r = nil) ⇒ ColumnExpr

Sets the attributes for the object to those given. The right ® is not required, it is used when aliasing. The left (l) usually specifies the column name, and the operator (op) is usually ‘ASC’, ‘DESC’, or ‘AS’.



81
82
83
# File 'lib/sequel_core/sql.rb', line 81

def initialize(l, op, r = nil)
  @l, @op, @r = l, op, r
end

Instance Attribute Details

#lObject (readonly)

Created readers for the left, operator, and right expression.



75
76
77
# File 'lib/sequel_core/sql.rb', line 75

def l
  @l
end

#opObject (readonly)

Created readers for the left, operator, and right expression.



75
76
77
# File 'lib/sequel_core/sql.rb', line 75

def op
  @op
end

#rObject (readonly)

Created readers for the left, operator, and right expression.



75
76
77
# File 'lib/sequel_core/sql.rb', line 75

def r
  @r
end

Instance Method Details

#to_s(ds) ⇒ Object

Delegate the creation of the resulting SQL to the given dataset, since it may be database dependent.



87
88
89
# File 'lib/sequel_core/sql.rb', line 87

def to_s(ds)
  ds.column_expr_sql(self)
end