diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/interface/src/collection.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/interface/src/collection.cpp index 4a7d28d92f8d2fd7be0f2f05a5a25af85f929faa..8c6d7970cf3449db99247ffe3d843275832b85ba 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/interface/src/collection.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/interface/src/collection.cpp @@ -166,7 +166,10 @@ int Collection::UpdateDocument(const std::string &id, const std::string &update) Value valueGot; errCode = executor_->GetData(name_, keyId, valueGot); std::string valueGotStr = std::string(valueGot.begin(), valueGot.end()); - if (errCode != E_OK) { + if (errCode == -E_NOT_FOUND) { + GLOGW("Get original document not found."); + return -E_NOT_FOUND; + } else if (errCode != E_OK) { GLOGE("Get original document failed. %d", errCode); return errCode; } diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/interface/src/document_store.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/interface/src/document_store.cpp index dd4055b4d73f79db91f4ae684cc0f209088b5de3..6d252f108ef454bbd062c0e8436bcf93a8499b6f 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/interface/src/document_store.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/interface/src/document_store.cpp @@ -193,6 +193,8 @@ int DocumentStore::UpdateDocument(const std::string &collection, const std::stri errCode = coll.UpdateDocument(docId, update); if (errCode == E_OK) { errCode = 1; // update one record. + } else if (errCode == -E_NOT_FOUND) { + errCode = E_OK; } return errCode; } diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/oh_adapter/src/sqlite_store_executor_impl.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/oh_adapter/src/sqlite_store_executor_impl.cpp index ffe8c7be611ff68a180a49778b206839d97becf4..9af80fa7621ce48d23c18fda23731270bb72d97e 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/oh_adapter/src/sqlite_store_executor_impl.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd_simple/src/oh_adapter/src/sqlite_store_executor_impl.cpp @@ -237,7 +237,7 @@ int SqliteStoreExecutor::DropCollection(const std::string &name, bool ignoreNonE } if (!isExists) { GLOGE("[sqlite executor] Drop collectoin failed, collection not exists."); - return -E_NO_DATA; + return -E_INVALID_ARGS; } } diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd_simple/test/unittest/api/documentdb_collection_test.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd_simple/test/unittest/api/documentdb_collection_test.cpp index a15df4df50029f45055142b9ed59b2bc9d47c19f..63b72d43685e6c81eaa88f5d050686704fe60819 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd_simple/test/unittest/api/documentdb_collection_test.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd_simple/test/unittest/api/documentdb_collection_test.cpp @@ -198,7 +198,7 @@ HWTEST_F(DocumentDBCollectionTest, CollectionTest006, TestSize.Level0) EXPECT_EQ(GRD_DropCollection(g_db, "student", 0), GRD_OK); EXPECT_EQ(GRD_DropCollection(g_db, "student", 0), GRD_OK); - EXPECT_EQ(GRD_DropCollection(g_db, "student", CHK_NON_EXIST_COLLECTION), GRD_NO_DATA); + EXPECT_EQ(GRD_DropCollection(g_db, "student", CHK_NON_EXIST_COLLECTION), GRD_INVALID_ARGS); // Create collection with different option returnh OK after drop collection EXPECT_EQ(GRD_CreateCollection(g_db, "student", R""({"maxDoc":2048})"", 0), GRD_OK); diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd_simple/test/unittest/api/documentdb_data_test.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd_simple/test/unittest/api/documentdb_data_test.cpp index 228978ba824e9bb241f7d184e494a684161d86cf..3295851de1d4ded49d00fa1db003b5320300ba31 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd_simple/test/unittest/api/documentdb_data_test.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd_simple/test/unittest/api/documentdb_data_test.cpp @@ -180,7 +180,7 @@ HWTEST_F(DocumentDBDataTest, UpsertDataTest007, TestSize.Level0) { std::string filter = R""({"_id":"1234"})""; std::string val = R""({"name":"Tmono","age":18,"addr":{"city":"shanghai","postal":200001}})""; - EXPECT_EQ(GRD_UpsertDoc(g_db, "collection_not_exists", filter.c_str(), val.c_str(), GRD_DOC_REPLACE), GRD_NO_DATA); + EXPECT_EQ(GRD_UpsertDoc(g_db, "collection_not_exists", filter.c_str(), val.c_str(), GRD_DOC_REPLACE), GRD_OK); } /** @@ -211,7 +211,7 @@ HWTEST_F(DocumentDBDataTest, UpdateDataTest001, TestSize.Level0) { std::string filter = R""({"_id":"1234"})""; std::string updateDoc = R""({"name":"Xue"})""; - EXPECT_EQ(GRD_UpdateDoc(g_db, g_coll, filter.c_str(), updateDoc.c_str(), 0), GRD_NO_DATA); + EXPECT_EQ(GRD_UpdateDoc(g_db, g_coll, filter.c_str(), updateDoc.c_str(), 0), GRD_OK); } /**