2019-04-03 11:03:07 +02:00
|
|
|
package sqlbuilder
|
|
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
type StringExpression interface {
|
2019-06-04 12:10:23 +02:00
|
|
|
Expression
|
2019-04-03 11:03:07 +02:00
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
EQ(rhs StringExpression) BoolExpression
|
|
|
|
|
NOT_EQ(rhs StringExpression) BoolExpression
|
|
|
|
|
IS_DISTINCT_FROM(rhs StringExpression) BoolExpression
|
|
|
|
|
IS_NOT_DISTINCT_FROM(rhs StringExpression) BoolExpression
|
2019-05-30 14:49:36 +02:00
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
LT(rhs StringExpression) BoolExpression
|
|
|
|
|
LT_EQ(rhs StringExpression) BoolExpression
|
|
|
|
|
GT(rhs StringExpression) BoolExpression
|
|
|
|
|
GT_EQ(rhs StringExpression) BoolExpression
|
|
|
|
|
|
2019-06-04 12:10:23 +02:00
|
|
|
CONCAT(rhs Expression) StringExpression
|
2019-06-02 13:43:43 +02:00
|
|
|
|
|
|
|
|
LIKE(pattern StringExpression) BoolExpression
|
|
|
|
|
NOT_LIKE(pattern StringExpression) BoolExpression
|
|
|
|
|
SIMILAR_TO(pattern StringExpression) BoolExpression
|
|
|
|
|
NOT_SIMILAR_TO(pattern StringExpression) BoolExpression
|
2019-04-03 11:03:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type stringInterfaceImpl struct {
|
2019-06-02 12:45:46 +02:00
|
|
|
parent StringExpression
|
2019-04-03 11:03:07 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
func (s *stringInterfaceImpl) EQ(rhs StringExpression) BoolExpression {
|
2019-05-29 14:03:38 +02:00
|
|
|
return EQ(s.parent, rhs)
|
2019-04-03 11:03:07 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
func (s *stringInterfaceImpl) NOT_EQ(rhs StringExpression) BoolExpression {
|
2019-05-29 14:03:38 +02:00
|
|
|
return NOT_EQ(s.parent, rhs)
|
2019-04-03 11:03:07 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
func (s *stringInterfaceImpl) IS_DISTINCT_FROM(rhs StringExpression) BoolExpression {
|
2019-05-30 14:49:36 +02:00
|
|
|
return IS_DISTINCT_FROM(s.parent, rhs)
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
func (s *stringInterfaceImpl) IS_NOT_DISTINCT_FROM(rhs StringExpression) BoolExpression {
|
2019-05-30 14:49:36 +02:00
|
|
|
return IS_NOT_DISTINCT_FROM(s.parent, rhs)
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
func (s *stringInterfaceImpl) GT(rhs StringExpression) BoolExpression {
|
2019-05-29 14:03:38 +02:00
|
|
|
return GT(s.parent, rhs)
|
2019-04-03 11:03:07 +02:00
|
|
|
}
|
2019-04-04 13:07:21 +02:00
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
func (s *stringInterfaceImpl) GT_EQ(rhs StringExpression) BoolExpression {
|
2019-05-29 14:03:38 +02:00
|
|
|
return GT_EQ(s.parent, rhs)
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
func (s *stringInterfaceImpl) LT(rhs StringExpression) BoolExpression {
|
2019-05-29 14:03:38 +02:00
|
|
|
return LT(s.parent, rhs)
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
func (s *stringInterfaceImpl) LT_EQ(rhs StringExpression) BoolExpression {
|
2019-05-29 14:03:38 +02:00
|
|
|
return LT_EQ(s.parent, rhs)
|
2019-04-04 13:07:21 +02:00
|
|
|
}
|
2019-06-02 12:45:46 +02:00
|
|
|
|
2019-06-04 12:10:23 +02:00
|
|
|
func (s *stringInterfaceImpl) CONCAT(rhs Expression) StringExpression {
|
2019-06-02 12:45:46 +02:00
|
|
|
return newBinaryStringExpression(s.parent, rhs, "||")
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-02 13:43:43 +02:00
|
|
|
func (s *stringInterfaceImpl) LIKE(pattern StringExpression) BoolExpression {
|
|
|
|
|
return newBinaryBoolExpression(s.parent, pattern, "LIKE")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *stringInterfaceImpl) NOT_LIKE(pattern StringExpression) BoolExpression {
|
|
|
|
|
return newBinaryBoolExpression(s.parent, pattern, "NOT LIKE")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *stringInterfaceImpl) SIMILAR_TO(pattern StringExpression) BoolExpression {
|
|
|
|
|
return newBinaryBoolExpression(s.parent, pattern, "SIMILAR TO")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *stringInterfaceImpl) NOT_SIMILAR_TO(pattern StringExpression) BoolExpression {
|
|
|
|
|
return newBinaryBoolExpression(s.parent, pattern, "NOT SIMILAR TO")
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-02 12:45:46 +02:00
|
|
|
//---------------------------------------------------//
|
|
|
|
|
type binaryStringExpression struct {
|
|
|
|
|
expressionInterfaceImpl
|
|
|
|
|
stringInterfaceImpl
|
|
|
|
|
|
|
|
|
|
binaryOpExpression
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-04 12:10:23 +02:00
|
|
|
func newBinaryStringExpression(lhs, rhs Expression, operator string) StringExpression {
|
2019-06-02 12:45:46 +02:00
|
|
|
boolExpression := binaryStringExpression{}
|
|
|
|
|
|
|
|
|
|
boolExpression.binaryOpExpression = newBinaryExpression(lhs, rhs, operator)
|
|
|
|
|
boolExpression.expressionInterfaceImpl.parent = &boolExpression
|
|
|
|
|
boolExpression.stringInterfaceImpl.parent = &boolExpression
|
|
|
|
|
|
|
|
|
|
return &boolExpression
|
|
|
|
|
}
|