Defines case methods
define({
Cast the reciever to the given SQL type.
Example
sql.a.cast("integer") //=> CAST(a AS integer)
sql.a.cast(String) //=> CAST(a AS varchar(255))
Arguments
patio.sql.Cast the casted expression
function (type){
return new Cast(this, type);
}
Cast the reciever to the given SQL type (or the database's default Number type if none given.
Example
sql.a.castNumeric() //=> CAST(a AS integer)
sql.a.castNumeric("double") //=> CAST(a AS double precision)
Arguments
the numeric type to cast to
patio.sql.NumericExpression a casted numberic expression
function (type){
return this.cast(type || "integer").sqlNumber;
}
Cast the reciever to the given SQL type (or the database's default String type if none given), and return the result as a patio.sql.StringExpression.
Example
sql.a.castString() //=> CAST(a AS varchar(255))
sql.a.castString("text") //=> CAST(a AS text)
Arguments
the string type to cast to
patio.sql.StringExpression the casted string expression
function (type){
return this.cast(type || String).sqlString;
}