Simplify literal expressions.

This commit is contained in:
go-jet 2026-02-02 13:21:35 +01:00
parent 4995a90483
commit 0e495a279e
26 changed files with 233 additions and 616 deletions

View file

@ -7,21 +7,19 @@ 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 {
ret := &cast{}
ret.Cast = jet.NewCastImpl(expr)
return ret
return &cast{
expr: expr,
}
}
type cast struct {
expr Expression
}
// AS casts expression as castType
func (b *cast) AS(castType string) Expression {
return b.Cast.AS(castType)
return jet.AtomicCustomExpression(b.expr, Token("::"+castType))
}
// AS_BOOL casts expression as bool type