From 4a0499a05ee987cd2e9278f4f17a38d0592c800c Mon Sep 17 00:00:00 2001 From: zqq Date: Sat, 1 Nov 2025 15:45:44 +0800 Subject: [PATCH] fix issue Signed-off-by: zqq --- frameworks/libs/distributeddb/common/src/schema_utils.cpp | 2 +- .../test/unittest/common/common/distributeddb_common_test.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/frameworks/libs/distributeddb/common/src/schema_utils.cpp b/frameworks/libs/distributeddb/common/src/schema_utils.cpp index 22c254748b8..30d707e37b4 100644 --- a/frameworks/libs/distributeddb/common/src/schema_utils.cpp +++ b/frameworks/libs/distributeddb/common/src/schema_utils.cpp @@ -178,7 +178,7 @@ int SchemaUtils::TransToLong(const std::string &defaultContent, SchemaAttribute return -E_SCHEMA_PARSE_FAIL; } auto defaultPos = defaultContent.find_first_not_of("+- "); - if (defaultPos >= defaultContent.size()) { + if (defaultPos == std::string::npos) { LOGE("Default value without +-"); return -E_SCHEMA_PARSE_FAIL; } diff --git a/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_common_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_common_test.cpp index 48bf72fd97d..4bff8b66ede 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_common_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_common_test.cpp @@ -865,5 +865,8 @@ HWTEST_F(DistributedDBCommonTest, SchemaUtilsTest002, TestSize.Level0) value = "INTEGER,DEFAULT -10000000000 "; errCode = SchemaUtils::ParseAndCheckSchemaAttribute(value, outAttr); EXPECT_EQ(errCode, -E_SCHEMA_PARSE_FAIL); + value = "INTEGER,DEFAULT +100"; + errCode = SchemaUtils::ParseAndCheckSchemaAttribute(value, outAttr); + EXPECT_EQ(errCode, E_OK); } } \ No newline at end of file -- Gitee