mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 08:50:46 +00:00
Implement STRINGEQUALS
This commit is contained in:
41
query_executors/memory_executor/string_functions.go
Normal file
41
query_executors/memory_executor/string_functions.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package memoryexecutor
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
)
|
||||
|
||||
func strings_StringEquals(arguments []interface{}, queryParameters map[string]interface{}, row RowType) bool {
|
||||
ignoreCase := false
|
||||
if len(arguments) > 2 && arguments[2] != nil {
|
||||
ignoreCaseItem := arguments[2].(parsers.SelectItem)
|
||||
if value, ok := getFieldValue(ignoreCaseItem, queryParameters, row).(bool); ok {
|
||||
ignoreCase = value
|
||||
}
|
||||
}
|
||||
|
||||
ex1Item := arguments[0].(parsers.SelectItem)
|
||||
ex2Item := arguments[1].(parsers.SelectItem)
|
||||
|
||||
ex1 := getFieldValue(ex1Item, queryParameters, row)
|
||||
ex2 := getFieldValue(ex2Item, queryParameters, row)
|
||||
|
||||
var ok bool
|
||||
var str1 string
|
||||
var str2 string
|
||||
|
||||
if str1, ok = ex1.(string); !ok {
|
||||
fmt.Println("StringEquals got parameters of wrong type")
|
||||
}
|
||||
if str2, ok = ex2.(string); !ok {
|
||||
fmt.Println("StringEquals got parameters of wrong type")
|
||||
}
|
||||
|
||||
if ignoreCase {
|
||||
return strings.EqualFold(str1, str2)
|
||||
}
|
||||
|
||||
return str1 == str2
|
||||
}
|
||||
Reference in New Issue
Block a user