Skip to content

Commit

Permalink
Merge pull request #2212 from kuzudb/utf8-slice-fix
Browse files Browse the repository at this point in the history
Fix list slice utf8
  • Loading branch information
ray6080 committed Oct 14, 2023
2 parents d24e91c + da6cee5 commit 1420ead
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/include/function/list/functions/list_slice_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstring>

#include "common/types/ku_list.h"
#include "function/string/functions/substr_function.h"

namespace kuzu {
namespace function {
Expand Down Expand Up @@ -31,9 +32,8 @@ struct ListSlice {
common::ValueVector& resultValueVector) {
int64_t startIdx = (begin == 0) ? 1 : begin;
int64_t endIdx = (end == 0) ? str.len : end;
result.len = std::min(endIdx - startIdx + 1, str.len - startIdx + 1);
common::StringVector::addString(
&resultValueVector, result, (const char*)(str.getData() + startIdx - 1), result.len);
SubStr::operation(str, startIdx, std::min(endIdx - startIdx + 1, str.len - startIdx + 1),
result, resultValueVector);
}
};

Expand Down
4 changes: 4 additions & 0 deletions test/test_files/tinysnb/function/list.test
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ sdwe
ad


-LOG SliceUTF8String
-STATEMENT Return '这是一个中文句子'[2:5]
---- 1
是一个中

-LOG ListLenStructuredListOfInts
-STATEMENT MATCH (a:person) RETURN len(a.workedHours)
Expand Down

0 comments on commit 1420ead

Please sign in to comment.