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-01 10:39:57 +02:00
|
|
|
jet.CastImpl
|
2019-07-31 18:43:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func CAST(expr jet.Expression) cast {
|
|
|
|
|
castImpl := &castImpl{}
|
|
|
|
|
|
2019-08-01 10:39:57 +02:00
|
|
|
castImpl.CastImpl = jet.NewCastImpl(expr)
|
2019-07-31 18:43:54 +02:00
|
|
|
|
|
|
|
|
return castImpl
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *castImpl) AS_DATETIME() DateTimeExpression {
|
2019-08-01 10:39:57 +02:00
|
|
|
return jet.TimestampExp(c.AS("DATETIME"))
|
2019-07-31 18:43:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *castImpl) AS_SIGNED() IntegerExpression {
|
2019-08-01 10:39:57 +02:00
|
|
|
return jet.IntExp(c.AS("SIGNED"))
|
2019-07-31 18:43:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *castImpl) AS_UNSIGNED() IntegerExpression {
|
2019-08-01 10:39:57 +02:00
|
|
|
return jet.IntExp(c.AS("UNSIGNED"))
|
2019-07-31 18:43:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *castImpl) AS_BINARY() StringExpression {
|
2019-08-01 10:39:57 +02:00
|
|
|
return jet.StringExp(c.AS("BINARY"))
|
2019-07-31 18:43:54 +02:00
|
|
|
}
|