Literal expressions clean up.

This commit is contained in:
go-jet 2019-08-16 11:19:06 +02:00
parent bcdab0f111
commit ba5ee27990
14 changed files with 78 additions and 36 deletions

View file

@ -30,7 +30,7 @@ type castImpl struct {
jet.Cast
}
func CAST(expr jet.Expression) cast {
func CAST(expr Expression) cast {
castImpl := &castImpl{}
castImpl.Cast = jet.NewCastImpl(expr)

View file

@ -30,3 +30,5 @@ var DateTimeExp = jet.TimestampExp
var TimestampExp = jet.TimestampExp
var Raw = jet.Raw
var NewEnumValue = jet.NewEnumValue

View file

@ -180,7 +180,7 @@ func CURRENT_TIMESTAMP(precision ...int) TimestampExpression {
// NOW returns current datetime
func NOW(fsp ...int) DateTimeExpression {
if len(fsp) > 0 {
return jet.NewTimestampFunc("NOW", Int(int64(fsp[0]), true))
return jet.NewTimestampFunc("NOW", jet.ConstLiteral(int64(fsp[0])))
}
return jet.NewTimestampFunc("NOW")
}

View file

@ -36,16 +36,6 @@ func SELECT(projection Projection, projections ...Projection) SelectStatement {
return newSelectStatement(nil, append([]Projection{projection}, projections...))
}
func toJetProjectionList(projections []Projection) []jet.Projection {
ret := []jet.Projection{}
for _, projection := range projections {
ret = append(ret, projection)
}
return ret
}
func newSelectStatement(table ReadableTable, projections []Projection) SelectStatement {
newSelect := &selectStatementImpl{}
newSelect.ExpressionStatementImpl.StatementImpl = jet.NewStatementImpl(Dialect, jet.SelectStatementType, newSelect, &newSelect.Select,

View file

@ -5,4 +5,12 @@ import "github.com/go-jet/jet/internal/jet"
type Statement jet.Statement
type Projection jet.Projection
var NewEnumValue = jet.NewEnumValue
func toJetProjectionList(projections []Projection) []jet.Projection {
ret := []jet.Projection{}
for _, projection := range projections {
ret = append(ret, projection)
}
return ret
}