From bcde3bc33f0a2e0ba08303c260aabbb2f3d0eaab Mon Sep 17 00:00:00 2001 From: Jeremyzz Date: Fri, 12 May 2023 08:48:01 +0800 Subject: [PATCH 1/5] fix find bug Signed-off-by: Jeremyzz --- .../gaussdb_rd/src/executor/document/check_common.cpp | 5 ++++- .../gaussdb_rd/test/unittest/api/documentdb_insert_test.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp index b65452a3..53da8a74 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp @@ -141,8 +141,11 @@ int CheckCommon::CheckDocument(JsonObject &documentObj) } bool isIdExist = true; int ret = CheckIdFormat(documentObj, isIdExist); - if (!isIdExist || ret != E_OK) { + if (!isIdExist) { GLOGE("Document Id format is illegal"); + return -E_INVALID_ARGS; + } + if (ret != E_OK) { return ret; } JsonObject documentObjChild = documentObj.GetChild(); diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_insert_test.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_insert_test.cpp index 4dc404b8..54be32da 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_insert_test.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/test/unittest/api/documentdb_insert_test.cpp @@ -820,4 +820,10 @@ HWTEST_F(DocumentDBInsertTest, DocumentDBInsertTest045, TestSize.Level1) const char *document1 = R""({"_id":"0123", "num.":"num"})""; EXPECT_EQ(GRD_InsertDoc(g_db, RIGHT_COLLECTION_NAME, document1, 0), GRD_INVALID_ARGS); } + +HWTEST_F(DocumentDBInsertTest, DocumentDBInsertTest046, TestSize.Level1) +{ + const char *document1 = R""({})""; + EXPECT_EQ(GRD_InsertDoc(g_db, RIGHT_COLLECTION_NAME, document1, 0), GRD_INVALID_ARGS); +} } // namespace -- Gitee From c1916a026a0991b20efe85a788fa0dcbbc3bed51 Mon Sep 17 00:00:00 2001 From: Jeremyzz Date: Fri, 12 May 2023 10:04:33 +0800 Subject: [PATCH 2/5] fix bug Signed-off-by: Jeremyzz --- .../gaussdb_rd/src/executor/document/check_common.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp index 53da8a74..3621420d 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp @@ -83,8 +83,7 @@ int CheckCommon::CheckFilter(JsonObject &filterObj, bool &isOnlyId, std::vector< return -E_INVALID_ARGS; } } - int errCode = E_OK; - if (!filterObj.GetObjectItem("_id", errCode).GetNext().IsNull() && errCode != E_OK) { + if(!filterObj.GetChild().GetNext().IsNull()) { // SecondLevel has not only one not isOnlyId = false; } for (size_t i = 0; i < filterPath.size(); i++) { -- Gitee From 4f562345528f57811316b2683fcce06d1b149007 Mon Sep 17 00:00:00 2001 From: Jeremyzz Date: Fri, 12 May 2023 10:29:47 +0800 Subject: [PATCH 3/5] fix code check opinion Signed-off-by: Jeremyzz --- .../gaussdb_rd/src/executor/document/check_common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp index 3621420d..91405ff1 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp @@ -83,7 +83,7 @@ int CheckCommon::CheckFilter(JsonObject &filterObj, bool &isOnlyId, std::vector< return -E_INVALID_ARGS; } } - if(!filterObj.GetChild().GetNext().IsNull()) { // SecondLevel has not only one not + if(!filterObj.GetChild().GetNext().IsNull()) { // This place is to determine whether there are other nodes at the same level as the id node isOnlyId = false; } for (size_t i = 0; i < filterPath.size(); i++) { -- Gitee From 093b49715420bff22f6ba22a73f9510492734647 Mon Sep 17 00:00:00 2001 From: Jeremyzz Date: Fri, 12 May 2023 10:40:54 +0800 Subject: [PATCH 4/5] fix code check Signed-off-by: Jeremyzz --- .../gaussdb_rd/src/executor/document/check_common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp index 91405ff1..70792700 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp @@ -83,7 +83,7 @@ int CheckCommon::CheckFilter(JsonObject &filterObj, bool &isOnlyId, std::vector< return -E_INVALID_ARGS; } } - if(!filterObj.GetChild().GetNext().IsNull()) { // This place is to determine whether there are other nodes at the same level as the id node + if (!filterObj.GetChild().GetNext().IsNull()) { // check contained other field at the same level as the id node isOnlyId = false; } for (size_t i = 0; i < filterPath.size(); i++) { -- Gitee From cdad98a5b50fc3f540070bfc8ba32ca828af9775 Mon Sep 17 00:00:00 2001 From: Jeremyzz Date: Fri, 12 May 2023 12:05:24 +0800 Subject: [PATCH 5/5] delete useless code Signed-off-by: Jeremyzz --- .../gaussdb_rd/src/executor/document/grd_document_api.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/grd_document_api.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/grd_document_api.cpp index 6bf15227..9c6cadda 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/grd_document_api.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/grd_document_api.cpp @@ -116,7 +116,6 @@ int32_t GRD_FindDoc(GRD_DB *db, const char *collectionName, Query query, uint32_ int ret = db->store_->FindDocument(collectionName, query.filter, query.projection, flags, grdResultSet); if (ret != E_OK) { delete grdResultSet; - *resultSet = nullptr; return TransferDocErr(ret); } *resultSet = grdResultSet; -- Gitee