Simplified creation of operator expression.
This commit is contained in:
parent
a2fbc4f53a
commit
57aa62f483
6 changed files with 75 additions and 102 deletions
|
|
@ -11,7 +11,7 @@ const (
|
|||
|
||||
// NOT returns negation of bool expression result
|
||||
func NOT(exp BoolExpression) BoolExpression {
|
||||
return newPrefixBoolOperator(exp, "NOT")
|
||||
return newPrefixBoolOperatorExpression(exp, "NOT")
|
||||
}
|
||||
|
||||
// BIT_NOT inverts every bit in integer expression result
|
||||
|
|
@ -19,52 +19,52 @@ func BIT_NOT(expr IntegerExpression) IntegerExpression {
|
|||
if literalExp, ok := expr.(LiteralExpression); ok {
|
||||
literalExp.SetConstant(true)
|
||||
}
|
||||
return newPrefixIntegerOperator(expr, "~")
|
||||
return newPrefixIntegerOperatorExpression(expr, "~")
|
||||
}
|
||||
|
||||
//----------- Comparison operators ---------------//
|
||||
|
||||
// EXISTS checks for existence of the rows in subQuery
|
||||
func EXISTS(subQuery Expression) BoolExpression {
|
||||
return newPrefixBoolOperator(subQuery, "EXISTS")
|
||||
return newPrefixBoolOperatorExpression(subQuery, "EXISTS")
|
||||
}
|
||||
|
||||
// Returns a representation of "a=b"
|
||||
func eq(lhs, rhs Expression) BoolExpression {
|
||||
return newBinaryBoolOperator(lhs, rhs, "=")
|
||||
return newBinaryBoolOperatorExpression(lhs, rhs, "=")
|
||||
}
|
||||
|
||||
// Returns a representation of "a!=b"
|
||||
func notEq(lhs, rhs Expression) BoolExpression {
|
||||
return newBinaryBoolOperator(lhs, rhs, "!=")
|
||||
return newBinaryBoolOperatorExpression(lhs, rhs, "!=")
|
||||
}
|
||||
|
||||
func isDistinctFrom(lhs, rhs Expression) BoolExpression {
|
||||
return newBinaryBoolOperator(lhs, rhs, "IS DISTINCT FROM")
|
||||
return newBinaryBoolOperatorExpression(lhs, rhs, "IS DISTINCT FROM")
|
||||
}
|
||||
|
||||
func isNotDistinctFrom(lhs, rhs Expression) BoolExpression {
|
||||
return newBinaryBoolOperator(lhs, rhs, "IS NOT DISTINCT FROM")
|
||||
return newBinaryBoolOperatorExpression(lhs, rhs, "IS NOT DISTINCT FROM")
|
||||
}
|
||||
|
||||
// Returns a representation of "a<b"
|
||||
func lt(lhs Expression, rhs Expression) BoolExpression {
|
||||
return newBinaryBoolOperator(lhs, rhs, "<")
|
||||
return newBinaryBoolOperatorExpression(lhs, rhs, "<")
|
||||
}
|
||||
|
||||
// Returns a representation of "a<=b"
|
||||
func ltEq(lhs, rhs Expression) BoolExpression {
|
||||
return newBinaryBoolOperator(lhs, rhs, "<=")
|
||||
return newBinaryBoolOperatorExpression(lhs, rhs, "<=")
|
||||
}
|
||||
|
||||
// Returns a representation of "a>b"
|
||||
func gt(lhs, rhs Expression) BoolExpression {
|
||||
return newBinaryBoolOperator(lhs, rhs, ">")
|
||||
return newBinaryBoolOperatorExpression(lhs, rhs, ">")
|
||||
}
|
||||
|
||||
// Returns a representation of "a>=b"
|
||||
func gtEq(lhs, rhs Expression) BoolExpression {
|
||||
return newBinaryBoolOperator(lhs, rhs, ">=")
|
||||
return newBinaryBoolOperatorExpression(lhs, rhs, ">=")
|
||||
}
|
||||
|
||||
// --------------- CASE operator -------------------//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue