jet/sqlite/cast.go

48 lines
1,004 B
Go
Raw Normal View History

package sqlite
import (
"github.com/go-jet/jet/v2/internal/jet"
)
2024-11-01 12:30:37 +01:00
type cast struct {
jet.Cast
}
// CAST function converts a expr (of any type) into latter specified datatype.
2024-11-01 12:30:37 +01:00
func CAST(expr Expression) *cast {
ret := &cast{}
ret.Cast = jet.NewCastImpl(expr)
return ret
}
// AS casts expressions to castType
2024-11-01 12:30:37 +01:00
func (c *cast) AS(castType string) Expression {
return c.Cast.AS(castType)
}
// AS_TEXT cast expression to TEXT type
2024-11-01 12:30:37 +01:00
func (c *cast) AS_TEXT() StringExpression {
return StringExp(c.AS("TEXT"))
}
// AS_NUMERIC cast expression to NUMERIC type
2024-11-01 12:30:37 +01:00
func (c *cast) AS_NUMERIC() FloatExpression {
return FloatExp(c.AS("NUMERIC"))
}
// AS_INTEGER cast expression to INTEGER type
2024-11-01 12:30:37 +01:00
func (c *cast) AS_INTEGER() IntegerExpression {
return IntExp(c.AS("INTEGER"))
}
// AS_REAL cast expression to REAL type
2024-11-01 12:30:37 +01:00
func (c *cast) AS_REAL() FloatExpression {
return FloatExp(c.AS("REAL"))
}
// AS_BLOB cast expression to BLOB type
2025-02-28 18:23:15 +01:00
func (c *cast) AS_BLOB() BlobExpression {
return BlobExp(c.AS("BLOB"))
}