mirror of
https://github.com/pikami/cosmium.git
synced 2026-06-13 15:57:18 +01:00
Implement REGEXMATCH function (#15)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
+929
-921
File diff suppressed because it is too large
Load Diff
@@ -681,6 +681,8 @@ ThreeArgumentStringFunctionExpression <- function:ThreeArgumentStringFunction ws
|
||||
functionType = parsers.FunctionCallEndsWith
|
||||
case "STARTSWITH":
|
||||
functionType = parsers.FunctionCallStartsWith
|
||||
case "REGEXMATCH":
|
||||
functionType = parsers.FunctionCallRegexMatch
|
||||
case "INDEX_OF":
|
||||
functionType = parsers.FunctionCallIndexOf
|
||||
}
|
||||
@@ -688,7 +690,7 @@ ThreeArgumentStringFunctionExpression <- function:ThreeArgumentStringFunction ws
|
||||
return createFunctionCall(functionType, []interface{}{ex1, ex2, ignoreCase})
|
||||
}
|
||||
|
||||
ThreeArgumentStringFunction <- ("CONTAINS"i / "ENDSWITH"i / "STARTSWITH"i / "INDEX_OF"i) {
|
||||
ThreeArgumentStringFunction <- ("CONTAINS"i / "ENDSWITH"i / "STARTSWITH"i / "REGEXMATCH"i / "INDEX_OF"i) {
|
||||
return string(c.text), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -168,6 +168,32 @@ func Test_Execute_StringFunctions(t *testing.T) {
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function REGEXMATCH()", func(t *testing.T) {
|
||||
testQueryParse(
|
||||
t,
|
||||
`SELECT REGEXMATCH(c.id, "aB c", "ix") FROM c`,
|
||||
parsers.SelectStmt{
|
||||
SelectItems: []parsers.SelectItem{
|
||||
{
|
||||
Type: parsers.SelectItemTypeFunctionCall,
|
||||
Value: parsers.FunctionCall{
|
||||
Type: parsers.FunctionCallRegexMatch,
|
||||
Arguments: []interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "id"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
testutils.SelectItem_Constant_String("aB c"),
|
||||
testutils.SelectItem_Constant_String("ix"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Table: parsers.Table{SelectItem: testutils.SelectItem_Path("c")},
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function INDEX_OF()", func(t *testing.T) {
|
||||
testQueryParse(
|
||||
t,
|
||||
|
||||
Reference in New Issue
Block a user