Module: Sequel::SQL::CastMethods
- Included in:
- ComplexExpression, GenericExpression, String, Symbol
- Defined in:
- lib/sequel/sql.rb,
lib/sequel/deprecated.rb
Overview
Holds methods that are used to cast objects to differen SQL types.
Instance Method Summary collapse
-
#cast(sql_type) ⇒ Object
Cast the reciever to the given SQL type.
- #cast_as(sql_type) ⇒ Object
-
#cast_numeric(sql_type = nil) ⇒ Object
Cast the reciever to the given SQL type (or integer if none given), and return the result as a NumericExpression.
-
#cast_string(sql_type = nil) ⇒ Object
Cast the reciever to the given SQL type (or text if none given), and return the result as a StringExpression, so you can use + directly on the result for SQL string concatenation.
Instance Method Details
#cast(sql_type) ⇒ Object
Cast the reciever to the given SQL type
181 182 183 |
# File 'lib/sequel/sql.rb', line 181 def cast(sql_type) Cast.new(self, sql_type) end |
#cast_as(sql_type) ⇒ Object
230 231 232 233 |
# File 'lib/sequel/deprecated.rb', line 230 def cast_as(sql_type) Sequel::Deprecation.deprecate('Sequel::SQL::CastMethods#cast_as', 'Use Sequel::SQL::CastMethods#cast') cast(sql_type) end |
#cast_numeric(sql_type = nil) ⇒ Object
Cast the reciever to the given SQL type (or integer if none given), and return the result as a NumericExpression.
187 188 189 |
# File 'lib/sequel/sql.rb', line 187 def cast_numeric(sql_type = nil) cast(sql_type || Integer).sql_number end |
#cast_string(sql_type = nil) ⇒ Object
Cast the reciever to the given SQL type (or text if none given), and return the result as a StringExpression, so you can use + directly on the result for SQL string concatenation.
194 195 196 |
# File 'lib/sequel/sql.rb', line 194 def cast_string(sql_type = nil) cast(sql_type || String).sql_string end |