mirror of https://gitee.com/bigwinds/arangodb
return error codes in case a babies remove operation fails (#6527)
This commit is contained in:
parent
611e4a7010
commit
22a527f3e6
|
@ -558,6 +558,7 @@ bool RestDocumentHandler::removeDocument() {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool const isMultiple = search.isArray();
|
||||
OperationResult result = trx->remove(collectionName, search, opOptions);
|
||||
|
||||
res = trx->finish(result.result);
|
||||
|
@ -574,7 +575,8 @@ bool RestDocumentHandler::removeDocument() {
|
|||
|
||||
generateDeleted(result, collectionName,
|
||||
TRI_col_type_e(trx->getCollectionType(collectionName)),
|
||||
trx->transactionContextPtr()->getVPackOptionsForDump());
|
||||
trx->transactionContextPtr()->getVPackOptionsForDump(),
|
||||
isMultiple);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "Basics/tri-strings.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Meta/conversion.h"
|
||||
#include "Rest/CommonDefines.h"
|
||||
#include "Rest/HttpRequest.h"
|
||||
#include "Transaction/Methods.h"
|
||||
#include "Transaction/StandaloneContext.h"
|
||||
|
@ -258,12 +259,35 @@ std::string RestVocbaseBaseHandler::assembleDocumentId(
|
|||
void RestVocbaseBaseHandler::generateSaved(
|
||||
arangodb::OperationResult const& result, std::string const& collectionName,
|
||||
TRI_col_type_e type, VPackOptions const* options, bool isMultiple) {
|
||||
generate20x(result, collectionName, type, options, isMultiple, rest::ResponseCode::CREATED);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Generate a result for successful delete
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestVocbaseBaseHandler::generateDeleted(
|
||||
arangodb::OperationResult const& result, std::string const& collectionName,
|
||||
TRI_col_type_e type, VPackOptions const* options, bool isMultiple) {
|
||||
generate20x(result, collectionName, type, options, isMultiple, rest::ResponseCode::OK);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief generates a HTTP 20x response
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestVocbaseBaseHandler::generate20x(
|
||||
arangodb::OperationResult const& result, std::string const& collectionName,
|
||||
TRI_col_type_e type, VPackOptions const* options, bool isMultiple,
|
||||
rest::ResponseCode waitForSyncResponseCode) {
|
||||
|
||||
if (result._options.waitForSync) {
|
||||
resetResponse(rest::ResponseCode::CREATED);
|
||||
resetResponse(waitForSyncResponseCode);
|
||||
} else {
|
||||
resetResponse(rest::ResponseCode::ACCEPTED);
|
||||
}
|
||||
|
||||
|
||||
if (isMultiple && !result.countErrorCodes.empty()) {
|
||||
VPackBuilder errorBuilder;
|
||||
errorBuilder.openObject();
|
||||
|
@ -275,31 +299,6 @@ void RestVocbaseBaseHandler::generateSaved(
|
|||
_response->setHeaderNC(StaticStrings::ErrorCodes, errorBuilder.toJson());
|
||||
}
|
||||
|
||||
generate20x(result, collectionName, type, options);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Generate a result for successful delete
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestVocbaseBaseHandler::generateDeleted(
|
||||
arangodb::OperationResult const& result, std::string const& collectionName,
|
||||
TRI_col_type_e type, VPackOptions const* options) {
|
||||
if (result._options.waitForSync) {
|
||||
resetResponse(rest::ResponseCode::OK);
|
||||
} else {
|
||||
resetResponse(rest::ResponseCode::ACCEPTED);
|
||||
}
|
||||
generate20x(result, collectionName, type, options);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief generates a HTTP 20x response
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestVocbaseBaseHandler::generate20x(
|
||||
arangodb::OperationResult const& result, std::string const& collectionName,
|
||||
TRI_col_type_e type, VPackOptions const* options) {
|
||||
VPackSlice slice = result.slice();
|
||||
if (slice.isNone()) {
|
||||
// will happen if silent == true
|
||||
|
|
|
@ -232,7 +232,8 @@ class RestVocbaseBaseHandler : public RestBaseHandler {
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void generate20x(arangodb::OperationResult const&, std::string const&,
|
||||
TRI_col_type_e, arangodb::velocypack::Options const*);
|
||||
TRI_col_type_e, arangodb::velocypack::Options const*,
|
||||
bool isMultiple, rest::ResponseCode waitForSyncResponseCode);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief generates message for a saved document
|
||||
|
@ -248,7 +249,7 @@ class RestVocbaseBaseHandler : public RestBaseHandler {
|
|||
|
||||
void generateDeleted(arangodb::OperationResult const& result,
|
||||
std::string const& collectionName, TRI_col_type_e type,
|
||||
arangodb::velocypack::Options const*);
|
||||
arangodb::velocypack::Options const*, bool isMultiple);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief generates document not found error message, no transaction info
|
||||
|
|
Loading…
Reference in New Issue