diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/src/json_common.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/src/json_common.cpp index b84a888ea8aab1b99ddeb4269e41075e837e880f..fb9f5430a0979ce61dd14e0caaaea57444b4ad8d 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/src/json_common.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/src/json_common.cpp @@ -223,9 +223,6 @@ std::vector> JsonCommon::ParsePath(const JsonObject &ro { std::vector> resultPath; JsonObject projectionJson = root.GetChild(); - if (projectionJson.IsNull()) { - GLOGE("projectionJson is null"); - } std::vector singlePath; errCode = ParseNode(projectionJson, singlePath, resultPath, true); return resultPath; diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/collection.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/collection.cpp index 94f962c8e2ba71eb144a808262447d98af5b5151..4337077eaaff27027f4a16370ab4ff22c358c693 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/collection.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/collection.cpp @@ -187,7 +187,6 @@ int Collection::UpdateDocument(const std::string &id, const std::string &update, GLOGE("Get original document failed. %d", errCode); return errCode; } - GLOGD("Update document value."); JsonObject originValue = JsonObject::Parse(valueGotStr, errCode, true); if (errCode != E_OK) { GLOGD("Parse original value failed. %d %s", errCode, valueGotStr.c_str()); diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/document_store.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/document_store.cpp index bf5e02a000dc85e9d010044fd6daf1fc3ed2ffad..ad57c3c18fa877886718ef2b6536ab16a5266598 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/document_store.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/document_store.cpp @@ -15,9 +15,9 @@ #include "document_store.h" +#include "check_common.h" #include "collection_option.h" #include "doc_errno.h" -#include "check_common.h" #include "grd_base/grd_type_export.h" #include "grd_resultset_inner.h" #include "log_print.h" @@ -560,52 +560,62 @@ int DocumentStore::EraseCollection(const std::string collectionName) return E_INVALID_ARGS; } +int JudgeViewType(size_t &index, ValueObject &leafItem, bool &viewType) +{ + switch (leafItem.GetValueType()) { + case ValueObject::ValueType::VALUE_BOOL: + if (leafItem.GetBoolValue()) { + if (index != 0 && !viewType) { + return -E_INVALID_ARGS; + } + viewType = true; + } else { + if (index != 0 && viewType) { + return E_INVALID_ARGS; + } + viewType = false; + } + break; + case ValueObject::ValueType::VALUE_STRING: + if (leafItem.GetStringValue() == "") { + if (index != 0 && !viewType) { + return -E_INVALID_ARGS; + } + viewType = true; + } else { + return -E_INVALID_ARGS; + } + break; + case ValueObject::ValueType::VALUE_NUMBER: + if (leafItem.GetIntValue() == 0) { + if (index != 0 && viewType) { + return -E_INVALID_ARGS; + } + viewType = false; + } else { + if (index != 0 && !viewType) { + return E_INVALID_ARGS; + } + viewType = true; + } + break; + default: + return E_INVALID_ARGS; + } + return E_OK; +} + int DocumentStore::GetViewType(JsonObject &jsonObj, bool &viewType) { std::vector leafValue = JsonCommon::GetLeafValue(jsonObj); if (leafValue.size() == 0) { return E_INVALID_ARGS; } + int ret = E_OK; for (size_t i = 0; i < leafValue.size(); i++) { - switch (leafValue[i].GetValueType()) { - case ValueObject::ValueType::VALUE_BOOL: - if (leafValue[i].GetBoolValue()) { - if (i != 0 && !viewType) { - return -E_INVALID_ARGS; - } - viewType = true; - } else { - if (i != 0 && viewType) { - return E_INVALID_ARGS; - } - viewType = false; - } - break; - case ValueObject::ValueType::VALUE_STRING: - if (leafValue[i].GetStringValue() == "") { - if (i != 0 && !viewType) { - return -E_INVALID_ARGS; - } - viewType = true; - } else { - return -E_INVALID_ARGS; - } - break; - case ValueObject::ValueType::VALUE_NUMBER: - if (leafValue[i].GetIntValue() == 0) { - if (i != 0 && viewType) { - return -E_INVALID_ARGS; - } - viewType = false; - } else { - if (i != 0 && !viewType) { - return E_INVALID_ARGS; - } - viewType = true; - } - break; - default: - return E_INVALID_ARGS; + ret = JudgeViewType(i, leafValue[i], viewType); + if (ret != E_OK) { + return ret; } } return E_OK; diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/json_object.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/json_object.cpp index 3609c481f92330a0b65b10a96cdc468459406ed3..d1790b289d1584f3b0453978e464b1e3e2266b13 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/json_object.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/json_object.cpp @@ -670,7 +670,6 @@ int JsonObject::DeleteItemOnTarget(const JsonFieldPath &path) cJSON *nodeFather = MoveToPath(cjson_, patherPath, caseSensitive_); if (nodeFather == nullptr) { - GLOGE("Delete item failed, json field path not found."); return -E_JSON_PATH_NOT_EXISTS; } @@ -703,7 +702,6 @@ int JsonObject::DeleteItemDeeplyOnTarget(const JsonFieldPath &path) cJSON *nodeFather = MoveToPath(cjson_, patherPath, caseSensitive_); if (nodeFather == nullptr) { - GLOGE("Delete item failed, json field path not found."); return -E_JSON_PATH_NOT_EXISTS; }