75 lines
2 KiB
Go
75 lines
2 KiB
Go
package sqlbuilder
|
|
|
|
type StringExpression interface {
|
|
expression
|
|
|
|
EQ(rhs StringExpression) BoolExpression
|
|
NOT_EQ(rhs StringExpression) BoolExpression
|
|
IS_DISTINCT_FROM(rhs StringExpression) BoolExpression
|
|
IS_NOT_DISTINCT_FROM(rhs StringExpression) BoolExpression
|
|
|
|
LT(rhs StringExpression) BoolExpression
|
|
LT_EQ(rhs StringExpression) BoolExpression
|
|
GT(rhs StringExpression) BoolExpression
|
|
GT_EQ(rhs StringExpression) BoolExpression
|
|
|
|
CONCAT(rhs expression) StringExpression
|
|
}
|
|
|
|
type stringInterfaceImpl struct {
|
|
parent StringExpression
|
|
}
|
|
|
|
func (s *stringInterfaceImpl) EQ(rhs StringExpression) BoolExpression {
|
|
return EQ(s.parent, rhs)
|
|
}
|
|
|
|
func (s *stringInterfaceImpl) NOT_EQ(rhs StringExpression) BoolExpression {
|
|
return NOT_EQ(s.parent, rhs)
|
|
}
|
|
|
|
func (s *stringInterfaceImpl) IS_DISTINCT_FROM(rhs StringExpression) BoolExpression {
|
|
return IS_DISTINCT_FROM(s.parent, rhs)
|
|
}
|
|
|
|
func (s *stringInterfaceImpl) IS_NOT_DISTINCT_FROM(rhs StringExpression) BoolExpression {
|
|
return IS_NOT_DISTINCT_FROM(s.parent, rhs)
|
|
}
|
|
|
|
func (s *stringInterfaceImpl) GT(rhs StringExpression) BoolExpression {
|
|
return GT(s.parent, rhs)
|
|
}
|
|
|
|
func (s *stringInterfaceImpl) GT_EQ(rhs StringExpression) BoolExpression {
|
|
return GT_EQ(s.parent, rhs)
|
|
}
|
|
|
|
func (s *stringInterfaceImpl) LT(rhs StringExpression) BoolExpression {
|
|
return LT(s.parent, rhs)
|
|
}
|
|
|
|
func (s *stringInterfaceImpl) LT_EQ(rhs StringExpression) BoolExpression {
|
|
return LT_EQ(s.parent, rhs)
|
|
}
|
|
|
|
func (s *stringInterfaceImpl) CONCAT(rhs expression) StringExpression {
|
|
return newBinaryStringExpression(s.parent, rhs, "||")
|
|
}
|
|
|
|
//---------------------------------------------------//
|
|
type binaryStringExpression struct {
|
|
expressionInterfaceImpl
|
|
stringInterfaceImpl
|
|
|
|
binaryOpExpression
|
|
}
|
|
|
|
func newBinaryStringExpression(lhs, rhs expression, operator string) StringExpression {
|
|
boolExpression := binaryStringExpression{}
|
|
|
|
boolExpression.binaryOpExpression = newBinaryExpression(lhs, rhs, operator)
|
|
boolExpression.expressionInterfaceImpl.parent = &boolExpression
|
|
boolExpression.stringInterfaceImpl.parent = &boolExpression
|
|
|
|
return &boolExpression
|
|
}
|