2019-06-21 13:56:57 +02:00
|
|
|
package jet
|
2019-04-03 14:18:58 +02:00
|
|
|
|
2019-06-02 18:12:44 +02:00
|
|
|
type TimeExpression interface {
|
2019-06-04 12:10:23 +02:00
|
|
|
Expression
|
2019-05-07 19:06:21 +02:00
|
|
|
|
2019-06-02 18:12:44 +02:00
|
|
|
EQ(rhs TimeExpression) BoolExpression
|
|
|
|
|
NOT_EQ(rhs TimeExpression) BoolExpression
|
|
|
|
|
IS_DISTINCT_FROM(rhs TimeExpression) BoolExpression
|
|
|
|
|
IS_NOT_DISTINCT_FROM(rhs TimeExpression) BoolExpression
|
2019-05-31 12:59:57 +02:00
|
|
|
|
2019-06-02 18:12:44 +02:00
|
|
|
LT(rhs TimeExpression) BoolExpression
|
|
|
|
|
LT_EQ(rhs TimeExpression) BoolExpression
|
|
|
|
|
GT(rhs TimeExpression) BoolExpression
|
|
|
|
|
GT_EQ(rhs TimeExpression) BoolExpression
|
2019-04-03 14:18:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type timeInterfaceImpl struct {
|
2019-06-02 18:12:44 +02:00
|
|
|
parent TimeExpression
|
2019-04-03 14:18:58 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-02 18:12:44 +02:00
|
|
|
func (t *timeInterfaceImpl) EQ(rhs TimeExpression) BoolExpression {
|
2019-06-27 19:55:21 +02:00
|
|
|
return eq(t.parent, rhs)
|
2019-04-03 14:18:58 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-02 18:12:44 +02:00
|
|
|
func (t *timeInterfaceImpl) NOT_EQ(rhs TimeExpression) BoolExpression {
|
2019-06-27 19:55:21 +02:00
|
|
|
return notEq(t.parent, rhs)
|
2019-04-03 14:18:58 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-02 18:12:44 +02:00
|
|
|
func (t *timeInterfaceImpl) IS_DISTINCT_FROM(rhs TimeExpression) BoolExpression {
|
2019-06-27 19:55:21 +02:00
|
|
|
return isDistinctFrom(t.parent, rhs)
|
2019-05-30 14:49:36 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-02 18:12:44 +02:00
|
|
|
func (t *timeInterfaceImpl) IS_NOT_DISTINCT_FROM(rhs TimeExpression) BoolExpression {
|
2019-06-27 19:55:21 +02:00
|
|
|
return isNotDistinctFrom(t.parent, rhs)
|
2019-05-30 14:49:36 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-02 18:12:44 +02:00
|
|
|
func (t *timeInterfaceImpl) LT(rhs TimeExpression) BoolExpression {
|
2019-06-27 19:55:21 +02:00
|
|
|
return lt(t.parent, rhs)
|
2019-04-03 14:18:58 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-02 18:12:44 +02:00
|
|
|
func (t *timeInterfaceImpl) LT_EQ(rhs TimeExpression) BoolExpression {
|
2019-06-27 19:55:21 +02:00
|
|
|
return ltEq(t.parent, rhs)
|
2019-04-03 14:18:58 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-02 18:12:44 +02:00
|
|
|
func (t *timeInterfaceImpl) GT(rhs TimeExpression) BoolExpression {
|
2019-06-27 19:55:21 +02:00
|
|
|
return gt(t.parent, rhs)
|
2019-04-03 14:18:58 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-02 18:12:44 +02:00
|
|
|
func (t *timeInterfaceImpl) GT_EQ(rhs TimeExpression) BoolExpression {
|
2019-06-27 19:55:21 +02:00
|
|
|
return gtEq(t.parent, rhs)
|
2019-04-03 14:18:58 +02:00
|
|
|
}
|
2019-05-06 14:01:50 +02:00
|
|
|
|
|
|
|
|
//---------------------------------------------------//
|
|
|
|
|
type prefixTimeExpression struct {
|
|
|
|
|
expressionInterfaceImpl
|
|
|
|
|
timeInterfaceImpl
|
|
|
|
|
|
2019-05-29 14:03:38 +02:00
|
|
|
prefixOpExpression
|
2019-05-06 14:01:50 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-04 12:10:23 +02:00
|
|
|
func newPrefixTimeExpression(operator string, expression Expression) TimeExpression {
|
2019-05-06 14:01:50 +02:00
|
|
|
timeExpr := prefixTimeExpression{}
|
2019-05-29 14:03:38 +02:00
|
|
|
timeExpr.prefixOpExpression = newPrefixExpression(expression, operator)
|
2019-05-06 14:01:50 +02:00
|
|
|
|
|
|
|
|
timeExpr.expressionInterfaceImpl.parent = &timeExpr
|
|
|
|
|
timeExpr.timeInterfaceImpl.parent = &timeExpr
|
|
|
|
|
|
|
|
|
|
return &timeExpr
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-04 12:10:23 +02:00
|
|
|
func INTERVAL(interval string) Expression {
|
2019-06-04 11:52:37 +02:00
|
|
|
return newPrefixTimeExpression("INTERVAL", literal(interval))
|
2019-05-06 14:01:50 +02:00
|
|
|
}
|
2019-06-07 14:23:14 +02:00
|
|
|
|
|
|
|
|
//---------------------------------------------------//
|
|
|
|
|
|
|
|
|
|
type timeExpressionWrapper struct {
|
|
|
|
|
timeInterfaceImpl
|
|
|
|
|
Expression
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newTimeExpressionWrap(expression Expression) TimeExpression {
|
|
|
|
|
timeExpressionWrap := timeExpressionWrapper{Expression: expression}
|
|
|
|
|
timeExpressionWrap.timeInterfaceImpl.parent = &timeExpressionWrap
|
|
|
|
|
return &timeExpressionWrap
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TimeExp(expression Expression) TimeExpression {
|
|
|
|
|
return newTimeExpressionWrap(expression)
|
|
|
|
|
}
|