jet/mysql/cast.go

43 lines
744 B
Go
Raw Normal View History

2019-07-31 18:43:54 +02:00
package mysql
import (
2019-08-03 14:10:47 +02:00
"github.com/go-jet/jet/internal/jet"
2019-07-31 18:43:54 +02:00
)
type cast interface {
2019-08-01 10:39:57 +02:00
jet.Cast
2019-07-31 18:43:54 +02:00
AS_DATETIME() DateTimeExpression
AS_SIGNED() IntegerExpression
AS_UNSIGNED() IntegerExpression
AS_BINARY() StringExpression
}
type castImpl struct {
2019-08-11 14:29:03 +02:00
jet.Cast
2019-07-31 18:43:54 +02:00
}
func CAST(expr jet.Expression) cast {
castImpl := &castImpl{}
2019-08-11 14:29:03 +02:00
castImpl.Cast = jet.NewCastImpl(expr)
2019-07-31 18:43:54 +02:00
return castImpl
}
func (c *castImpl) AS_DATETIME() DateTimeExpression {
return DateTimeExp(c.AS("DATETIME"))
}
2019-07-31 18:43:54 +02:00
func (c *castImpl) AS_SIGNED() IntegerExpression {
return IntExp(c.AS("SIGNED"))
2019-07-31 18:43:54 +02:00
}
func (c *castImpl) AS_UNSIGNED() IntegerExpression {
return IntExp(c.AS("UNSIGNED"))
2019-07-31 18:43:54 +02:00
}
func (c *castImpl) AS_BINARY() StringExpression {
return StringExp(c.AS("BINARY"))
2019-07-31 18:43:54 +02:00
}