mirror of
https://gitee.com/rulego/streamsql.git
synced 2026-05-17 09:14:09 +00:00
fix:优化SubstringFunction负数处理逻辑
This commit is contained in:
@@ -295,6 +295,9 @@ func (f *SubstringFunction) Execute(ctx *FunctionContext, args []interface{}) (i
|
||||
}
|
||||
|
||||
strLen := int64(len(str))
|
||||
if start < 0 {
|
||||
start = strLen + start
|
||||
}
|
||||
if start < 0 || start >= strLen {
|
||||
return "", nil
|
||||
}
|
||||
@@ -308,6 +311,10 @@ func (f *SubstringFunction) Execute(ctx *FunctionContext, args []interface{}) (i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if length < 0 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
end := start + length
|
||||
if end > strLen {
|
||||
end = strLen
|
||||
|
||||
Reference in New Issue
Block a user