jet/mysql/literal.go

103 lines
3 KiB
Go
Raw Permalink Normal View History

package mysql
import (
"time"
"source.gleipnir.technology/Gleipnir/jet/v2/internal/jet"
)
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
2021-02-22 13:58:28 -05:00
// Int is constructor for 64 bit signed integer expressions literals.
var Int = jet.Int
2019-08-17 10:43:16 +02:00
2021-02-22 13:58:28 -05:00
// Int8 is constructor for 8 bit signed integer expressions literals.
var Int8 = jet.Int8
// Int16 is constructor for 16 bit signed integer expressions literals.
var Int16 = jet.Int16
// Int32 is constructor for 32 bit signed integer expressions literals.
var Int32 = jet.Int32
// Int64 is constructor for 64 bit signed integer expressions literals.
var Int64 = jet.Int
// Uint8 is constructor for 8 bit unsigned integer expressions literals.
var Uint8 = jet.Uint8
// Uint16 is constructor for 16 bit unsigned integer expressions literals.
var Uint16 = jet.Uint16
// Uint32 is constructor for 32 bit unsigned integer expressions literals.
var Uint32 = jet.Uint32
// Uint64 is constructor for 64 bit unsigned integer expressions literals.
var Uint64 = jet.Uint64
// Float creates new float literal expression from float64 value
var Float = jet.Float
2019-08-17 10:43:16 +02:00
// Decimal creates new float literal expression from string value
var Decimal = jet.Decimal
2019-08-17 10:43:16 +02:00
// String creates new string literal expression
var String = jet.String
// UUID is a helper function to create string literal expression from uuid object
// value can be any uuid type with a String method
var UUID = jet.UUID
2025-02-28 18:23:15 +01:00
// Blob creates new blob literal expression
func Blob(data []byte) BlobExpression {
return BlobExp(jet.Literal(data))
}
2019-08-17 10:43:16 +02:00
// Date creates new date literal
2022-05-16 11:51:47 +02:00
func Date(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
2022-05-16 11:51:47 +02:00
func DateT(t time.Time) DateExpression {
return CAST(jet.DateT(t)).AS_DATE()
}
2019-08-17 10:43:16 +02:00
// Time creates new time literal
2022-05-16 11:51:47 +02:00
func Time(hour, minute, second int, nanoseconds ...time.Duration) TimeExpression {
2019-08-13 10:16:26 +02:00
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
2022-05-16 11:51:47 +02:00
func TimeT(t time.Time) TimeExpression {
return CAST(jet.TimeT(t)).AS_TIME()
}
2019-08-17 10:43:16 +02:00
// DateTime creates new datetime literal
2022-05-16 11:51:47 +02:00
func DateTime(year int, month time.Month, day, hour, minute, second int, nanoseconds ...time.Duration) DateTimeExpression {
2019-08-13 10:16:26 +02:00
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
2022-05-16 11:51:47 +02:00
func DateTimeT(t time.Time) DateTimeExpression {
return CAST(jet.TimestampT(t)).AS_DATETIME()
}
2019-08-17 10:43:16 +02:00
// Timestamp creates new timestamp literal
2022-05-16 11:51:47 +02:00
func Timestamp(year int, month time.Month, day, hour, minute, second int, nanoseconds ...time.Duration) TimestampExpression {
2019-08-13 10:16:26 +02:00
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
2022-05-16 11:51:47 +02:00
func TimestampT(t time.Time) TimestampExpression {
return TIMESTAMP(StringExp(jet.TimestampT(t)))
}