Timestamp function instead of CAST for literal construct.
This commit is contained in:
parent
d235385c2a
commit
fbf5fbddbc
4 changed files with 35 additions and 28 deletions
|
|
@ -8,7 +8,6 @@ type cast interface {
|
|||
jet.Cast
|
||||
|
||||
AS_DATETIME() DateTimeExpression
|
||||
AS_TIMESTAMP() TimestampExpression
|
||||
AS_SIGNED() IntegerExpression
|
||||
AS_UNSIGNED() IntegerExpression
|
||||
AS_BINARY() StringExpression
|
||||
|
|
@ -27,21 +26,17 @@ func CAST(expr jet.Expression) cast {
|
|||
}
|
||||
|
||||
func (c *castImpl) AS_DATETIME() DateTimeExpression {
|
||||
return jet.TimestampExp(c.AS("DATETIME"))
|
||||
}
|
||||
|
||||
func (c *castImpl) AS_TIMESTAMP() TimestampExpression {
|
||||
return jet.TimestampExp(c.AS("DATETIME"))
|
||||
return DateTimeExp(c.AS("DATETIME"))
|
||||
}
|
||||
|
||||
func (c *castImpl) AS_SIGNED() IntegerExpression {
|
||||
return jet.IntExp(c.AS("SIGNED"))
|
||||
return IntExp(c.AS("SIGNED"))
|
||||
}
|
||||
|
||||
func (c *castImpl) AS_UNSIGNED() IntegerExpression {
|
||||
return jet.IntExp(c.AS("UNSIGNED"))
|
||||
return IntExp(c.AS("UNSIGNED"))
|
||||
}
|
||||
|
||||
func (c *castImpl) AS_BINARY() StringExpression {
|
||||
return jet.StringExp(c.AS("BINARY"))
|
||||
return StringExp(c.AS("BINARY"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,14 @@ func NOW(fsp ...int) DateTimeExpression {
|
|||
return jet.NewTimestampFunc("NOW")
|
||||
}
|
||||
|
||||
func TIMESTAMP(str StringExpression) TimestampExpression {
|
||||
return jet.NewTimestampFunc("TIMESTAMP", str)
|
||||
}
|
||||
|
||||
func UNIX_TIMESTAMP(str StringExpression) TimestampExpression {
|
||||
return jet.NewTimestampFunc("UNIX_TIMESTAMP", str)
|
||||
}
|
||||
|
||||
// --------------- Conditional Expressions Functions -------------//
|
||||
var COALESCE = jet.COALESCE
|
||||
var NULLIF = jet.NULLIF
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ var DateTimeT = func(t time.Time) DateTimeExpression {
|
|||
return CAST(jet.TimestampT(t)).AS_DATETIME()
|
||||
}
|
||||
var Timestamp = func(year int, month time.Month, day, hour, minute, second int, milliseconds ...int) TimestampExpression {
|
||||
return CAST(jet.Timestamp(year, month, day, hour, minute, second, milliseconds...)).AS_TIMESTAMP()
|
||||
return TIMESTAMP(StringExp(jet.Timestamp(year, month, day, hour, minute, second, milliseconds...)))
|
||||
}
|
||||
var TimestampT = func(t time.Time) TimestampExpression {
|
||||
return CAST(jet.TimestampT(t)).AS_TIMESTAMP()
|
||||
return TIMESTAMP(StringExp(jet.TimestampT(t)))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue