Module: Sequel::SQL::ColumnMethods
- Included in:
- Expression, String, Symbol
- Defined in:
- lib/sequel_core/sql.rb
Overview
Holds methods that should be called on columns only.
Constant Summary collapse
- AS =
'AS'.freeze
- DESC =
'DESC'.freeze
- ASC =
'ASC'.freeze
Instance Method Summary collapse
-
#as(a) ⇒ Object
Create an SQL column alias of the receiving column to the given alias.
-
#asc ⇒ Object
Mark the receiving SQL column as sorting in an ascending fashion (generally a no-op).
-
#cast_as(t) ⇒ Object
Cast the reciever to the given SQL type.
-
#desc ⇒ Object
Mark the receiving SQL column as sorting in a descending fashion.
Instance Method Details
#as(a) ⇒ Object
Create an SQL column alias of the receiving column to the given alias.
16 17 18 |
# File 'lib/sequel_core/sql.rb', line 16 def as(a) ColumnExpr.new(self, AS, a) end |
#asc ⇒ Object
Mark the receiving SQL column as sorting in an ascending fashion (generally a no-op).
26 27 28 |
# File 'lib/sequel_core/sql.rb', line 26 def asc ColumnExpr.new(self, ASC) end |
#cast_as(t) ⇒ Object
Cast the reciever to the given SQL type
31 32 33 34 |
# File 'lib/sequel_core/sql.rb', line 31 def cast_as(t) t = t.to_s.lit if t.is_a?(Symbol) Sequel::SQL::Function.new(:cast, self.as(t)) end |
#desc ⇒ Object
Mark the receiving SQL column as sorting in a descending fashion.
21 22 23 |
# File 'lib/sequel_core/sql.rb', line 21 def desc ColumnExpr.new(self, DESC) end |