diff --git a/frameworks/libs/distributeddb/common/src/schema_utils.cpp b/frameworks/libs/distributeddb/common/src/schema_utils.cpp index 22c254748b84f58164325c4fad0f0622180f4f0c..30d707e37b4df20aebc31d1cb0eb59c4557c9142 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 48bf72fd97d4a4c30199ca8e87b9278b97920176..4bff8b66ede59d904eec74c104f992c3c72cea6c 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