Implement IN function

This commit is contained in:
Pijus Kamandulis
2024-02-24 17:26:16 +02:00
parent 332be181ef
commit f37c664c1a
7 changed files with 394 additions and 154 deletions

View File

@@ -306,7 +306,7 @@ BooleanLiteral <- ("true"i / "false"i) {
return parsers.Constant{Type: parsers.ConstantTypeBoolean, Value: boolValue}, nil
}
FunctionCall <- StringFunctions / IsDefined
FunctionCall <- StringFunctions / IsDefined / InFunction
StringFunctions <- StringEqualsExpression
/ ToStringExpression
@@ -352,6 +352,11 @@ IsDefined <- "IS_DEFINED"i ws "(" ws ex:SelectItem ws ")" {
return parsers.FunctionCall{Type: parsers.FunctionCallIsDefined, Arguments: []interface{}{ex}}, nil
}
InFunction <- ex1:SelectProperty ws "IN"i ws "(" ws ex2:SelectItem others:(ws "," ws ex:SelectItem { return ex, nil })* ws ")" {
arguments := append([]interface{}{ex1, ex2}, others.([]interface{})...)
return parsers.FunctionCall{Type: parsers.FunctionCallIn, Arguments: arguments}, nil
}
Integer <- [0-9]+ {
return strconv.Atoi(string(c.text))
}