2019-04-03 14:18:58 +02:00
|
|
|
package sqlbuilder
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
type timeExpression interface {
|
|
|
|
|
expression
|
|
|
|
|
|
|
|
|
|
Eq(expression timeExpression) boolExpression
|
|
|
|
|
EqL(literal string) boolExpression
|
|
|
|
|
NotEq(expression timeExpression) boolExpression
|
|
|
|
|
NotEqL(literal string) boolExpression
|
|
|
|
|
GtEq(rhs timeExpression) boolExpression
|
|
|
|
|
GtEqL(literal string) boolExpression
|
|
|
|
|
LtEq(rhs timeExpression) boolExpression
|
|
|
|
|
LtEqL(literal string) boolExpression
|
2019-04-03 14:18:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type timeInterfaceImpl struct {
|
2019-05-07 19:06:21 +02:00
|
|
|
parent timeExpression
|
2019-04-03 14:18:58 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
func (t *timeInterfaceImpl) Eq(expression timeExpression) boolExpression {
|
2019-04-03 14:18:58 +02:00
|
|
|
return Eq(t.parent, expression)
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
func (t *timeInterfaceImpl) EqL(literal string) boolExpression {
|
2019-04-03 14:18:58 +02:00
|
|
|
return Eq(t.parent, Literal(literal))
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
func (t *timeInterfaceImpl) NotEq(expression timeExpression) boolExpression {
|
2019-04-03 14:18:58 +02:00
|
|
|
return NotEq(t.parent, expression)
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
func (t *timeInterfaceImpl) NotEqL(literal string) boolExpression {
|
2019-04-03 14:18:58 +02:00
|
|
|
return NotEq(t.parent, Literal(literal))
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
func (t *timeInterfaceImpl) GtEq(expression timeExpression) boolExpression {
|
2019-04-03 14:18:58 +02:00
|
|
|
return GtEq(t.parent, expression)
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
func (t *timeInterfaceImpl) GtEqL(literal string) boolExpression {
|
2019-04-03 14:18:58 +02:00
|
|
|
return GtEq(t.parent, Literal(literal))
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
func (t *timeInterfaceImpl) LtEq(expression timeExpression) boolExpression {
|
2019-04-03 14:18:58 +02:00
|
|
|
return LtEq(t.parent, expression)
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
func (t *timeInterfaceImpl) LtEqL(literal string) boolExpression {
|
2019-04-03 14:18:58 +02:00
|
|
|
return LtEq(t.parent, Literal(literal))
|
|
|
|
|
}
|
2019-05-06 14:01:50 +02:00
|
|
|
|
|
|
|
|
//---------------------------------------------------//
|
|
|
|
|
type prefixTimeExpression struct {
|
|
|
|
|
expressionInterfaceImpl
|
|
|
|
|
timeInterfaceImpl
|
|
|
|
|
|
|
|
|
|
prefixExpression
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
func newPrefixTimeExpression(expression expression, operator string) timeExpression {
|
2019-05-06 14:01:50 +02:00
|
|
|
timeExpr := prefixTimeExpression{}
|
|
|
|
|
timeExpr.prefixExpression = newPrefixExpression(expression, operator)
|
|
|
|
|
|
|
|
|
|
timeExpr.expressionInterfaceImpl.parent = &timeExpr
|
|
|
|
|
timeExpr.timeInterfaceImpl.parent = &timeExpr
|
|
|
|
|
|
|
|
|
|
return &timeExpr
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
func INTERVAL(interval string) expression {
|
2019-05-06 14:01:50 +02:00
|
|
|
return newPrefixTimeExpression(Literal(interval), "INTERVAL")
|
|
|
|
|
}
|