From 9b1919a8ebfff3789cebafd1da95ed93d14bbdb3 Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 4 Sep 2025 16:40:44 -0700 Subject: [PATCH] int range --- weed/query/engine/string_functions.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/weed/query/engine/string_functions.go b/weed/query/engine/string_functions.go index 450584b8e..21d4c8570 100644 --- a/weed/query/engine/string_functions.go +++ b/weed/query/engine/string_functions.go @@ -147,8 +147,8 @@ func (e *SQLEngine) Substring(value *schema_pb.Value, start *schema_pb.Value, le if lengthVal <= 0 { result = "" } else { - if lengthVal > int64(math.MaxInt) { - // If length is too large, take substring from startIdx to end + if lengthVal > int64(math.MaxInt) || lengthVal < int64(math.MinInt) { + // If length is out-of-bounds for int, take substring from startIdx to end result = str[startIdx:] } else { endIdx := startIdx + int(lengthVal) @@ -277,7 +277,7 @@ func (e *SQLEngine) Left(value *schema_pb.Value, length *schema_pb.Value) (*sche }, nil } - if lengthVal > int64(math.MaxInt) { + if lengthVal > int64(math.MaxInt) || lengthVal < int64(math.MinInt) { return &schema_pb.Value{ Kind: &schema_pb.Value_StringValue{StringValue: str}, }, nil @@ -316,7 +316,7 @@ func (e *SQLEngine) Right(value *schema_pb.Value, length *schema_pb.Value) (*sch }, nil } - if lengthVal > int64(math.MaxInt) { + if lengthVal > int64(math.MaxInt) || lengthVal < int64(math.MinInt) { return &schema_pb.Value{ Kind: &schema_pb.Value_StringValue{StringValue: str}, }, nil