Module | Sequel::SQL::CastMethods
In: | lib/sequel/sql.rb

Holds methods that are used to cast objects to different SQL types.

### Methods

cast cast_numeric cast_string

### Public Instance methods

cast(sql_type)

Cast the reciever to the given SQL type. You can specify a ruby class as a type, and it is handled similarly to using a database independent type in the schema methods.

      :a.cast(:integer) # CAST(a AS integer)
      :a.cast(String) # CAST(a AS varchar(255))

[Source]

         # File lib/sequel/sql.rb, line 292
    292:       def cast(sql_type)
    293:         Cast.new(self, sql_type)
    294:       end

cast_numeric(sql_type = nil)

Cast the reciever to the given SQL type (or the database‘s default Integer type if none given), and return the result as a `NumericExpression`, so you can use the bitwise operators on the result.

      :a.cast_numeric # CAST(a AS integer)
      :a.cast_numeric(Float) # CAST(a AS double precision)

[Source]

         # File lib/sequel/sql.rb, line 302
    302:       def cast_numeric(sql_type = nil)
    303:         cast(sql_type || Integer).sql_number
    304:       end

cast_string(sql_type = nil)

Cast the reciever to the given SQL type (or the database‘s default String type if none given), and return the result as a `StringExpression`, so you can use + directly on the result for SQL string concatenation.

      :a.cast_string # CAST(a AS varchar(255))
      :a.cast_string(:text) # CAST(a AS text)

[Source]

         # File lib/sequel/sql.rb, line 312
    312:       def cast_string(sql_type = nil)
    313:         cast(sql_type || String).sql_string
    314:       end

[Validate]