jet/mysql/literal.go

66 lines
1.9 KiB
Go
Raw Normal View History

package mysql
import (
"github.com/go-jet/jet/internal/jet"
"time"
)
2019-08-17 10:43:16 +02:00
// Keywords
var (
STAR = jet.STAR
NULL = jet.NULL
DEFAULT = jet.DEFAULT
)
2019-08-11 12:13:59 +02:00
2019-08-17 10:43:16 +02:00
// Bool creates new bool literal expression
var Bool = jet.Bool
2019-08-17 10:43:16 +02:00
// Int is constructor for integer expressions literals.
var Int = jet.Int
2019-08-17 10:43:16 +02:00
// Float creates new float literal expression
var Float = jet.Float
2019-08-17 10:43:16 +02:00
// String creates new string literal expression
var String = jet.String
2019-08-17 10:43:16 +02:00
// Date creates new date literal
var Date = func(year int, month time.Month, day int) DateExpression {
return CAST(jet.Date(year, month, day)).AS_DATE()
}
2019-08-17 10:43:16 +02:00
// DateT creates new date literal from time.Time
var DateT = func(t time.Time) DateExpression {
return CAST(jet.DateT(t)).AS_DATE()
}
2019-08-17 10:43:16 +02:00
// Time creates new time literal
2019-08-13 10:16:26 +02:00
var Time = func(hour, minute, second int, nanoseconds ...time.Duration) TimeExpression {
return CAST(jet.Time(hour, minute, second, nanoseconds...)).AS_TIME()
}
2019-08-17 10:43:16 +02:00
// TimeT creates new time literal from time.Time
var TimeT = func(t time.Time) TimeExpression {
return CAST(jet.TimeT(t)).AS_TIME()
}
2019-08-17 10:43:16 +02:00
// DateTime creates new datetime literal
2019-08-13 10:16:26 +02:00
var DateTime = func(year int, month time.Month, day, hour, minute, second int, nanoseconds ...time.Duration) DateTimeExpression {
return CAST(jet.Timestamp(year, month, day, hour, minute, second, nanoseconds...)).AS_DATETIME()
}
2019-08-17 10:43:16 +02:00
// DateTimeT creates new datetime literal from time.Time
var DateTimeT = func(t time.Time) DateTimeExpression {
return CAST(jet.TimestampT(t)).AS_DATETIME()
}
2019-08-17 10:43:16 +02:00
// Timestamp creates new timestamp literal
2019-08-13 10:16:26 +02:00
var Timestamp = func(year int, month time.Month, day, hour, minute, second int, nanoseconds ...time.Duration) TimestampExpression {
return TIMESTAMP(StringExp(jet.Timestamp(year, month, day, hour, minute, second, nanoseconds...)))
}
2019-08-17 10:43:16 +02:00
// TimestampT creates new timestamp literal from time.Time
var TimestampT = func(t time.Time) TimestampExpression {
return TIMESTAMP(StringExp(jet.TimestampT(t)))
}