Simplify literal expressions.
This commit is contained in:
parent
4995a90483
commit
0e495a279e
26 changed files with 233 additions and 616 deletions
|
|
@ -4,21 +4,20 @@ import (
|
|||
"github.com/go-jet/jet/v2/internal/jet"
|
||||
)
|
||||
|
||||
type cast struct {
|
||||
jet.Cast
|
||||
// CAST function converts an expr (of any type) into later specified datatype.
|
||||
func CAST(expr Expression) *cast {
|
||||
return &cast{
|
||||
expr: expr,
|
||||
}
|
||||
}
|
||||
|
||||
// CAST function converts a expr (of any type) into latter specified datatype.
|
||||
func CAST(expr Expression) *cast {
|
||||
ret := &cast{}
|
||||
ret.Cast = jet.NewCastImpl(expr)
|
||||
|
||||
return ret
|
||||
type cast struct {
|
||||
expr Expression
|
||||
}
|
||||
|
||||
// AS casts expressions to castType
|
||||
func (c *cast) AS(castType string) Expression {
|
||||
return c.Cast.AS(castType)
|
||||
return jet.AtomicCustomExpression(Token("CAST("), c.expr, Token("AS "+castType+")"))
|
||||
}
|
||||
|
||||
// AS_TEXT cast expression to TEXT type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue