mirror of https://gitee.com/bigwinds/arangodb
fix it! (#10198)
This commit is contained in:
parent
b35674dffa
commit
69dc50622a
|
@ -381,6 +381,7 @@ void RestVocbaseBaseHandler::generatePreconditionFailed(VPackSlice const& slice)
|
|||
VPackValue(static_cast<int32_t>(rest::ResponseCode::PRECONDITION_FAILED)));
|
||||
builder.add(StaticStrings::ErrorNum, VPackValue(TRI_ERROR_ARANGO_CONFLICT));
|
||||
builder.add(StaticStrings::ErrorMessage, VPackValue("precondition failed"));
|
||||
|
||||
if (slice.isObject()) {
|
||||
builder.add(StaticStrings::IdString, slice.get(StaticStrings::IdString));
|
||||
builder.add(StaticStrings::KeyString, slice.get(StaticStrings::KeyString));
|
||||
|
@ -487,7 +488,7 @@ void RestVocbaseBaseHandler::generateTransactionError(std::string const& collect
|
|||
return;
|
||||
|
||||
case TRI_ERROR_ARANGO_CONFLICT:
|
||||
if (result.buffer != nullptr) {
|
||||
if (result.buffer != nullptr && !result.slice().isNone()) {
|
||||
// This case happens if we come via the generateTransactionError that
|
||||
// has a proper OperationResult with a slice:
|
||||
generatePreconditionFailed(result.slice());
|
||||
|
|
|
@ -1605,7 +1605,7 @@ Future<OperationResult> transaction::Methods::insertLocal(std::string const& cna
|
|||
ManagedDocumentResult docResult;
|
||||
ManagedDocumentResult prevDocResult; // return OLD (with override option)
|
||||
|
||||
auto workForOneDocument = [&](VPackSlice const value) -> Result {
|
||||
auto workForOneDocument = [&](VPackSlice const value, bool isBabies) -> Result {
|
||||
if (!value.isObject()) {
|
||||
return Result(TRI_ERROR_ARANGO_DOCUMENT_TYPE_INVALID);
|
||||
}
|
||||
|
@ -1643,7 +1643,13 @@ Future<OperationResult> transaction::Methods::insertLocal(std::string const& cna
|
|||
|
||||
if (res.fail()) {
|
||||
// Error reporting in the babies case is done outside of here,
|
||||
// in the single document case no body needs to be created at all.
|
||||
if (res.is(TRI_ERROR_ARANGO_CONFLICT) && !isBabies) {
|
||||
TRI_ASSERT(prevDocResult.revisionId() != 0);
|
||||
|
||||
arangodb::velocypack::StringRef key = value.get(StaticStrings::KeyString).stringRef();
|
||||
buildDocumentIdentity(collection.get(), resultBuilder, cid, key, prevDocResult.revisionId(),
|
||||
0, nullptr, nullptr);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1674,14 +1680,14 @@ Future<OperationResult> transaction::Methods::insertLocal(std::string const& cna
|
|||
if (value.isArray()) {
|
||||
VPackArrayBuilder b(&resultBuilder);
|
||||
for (auto const& s : VPackArrayIterator(value)) {
|
||||
res = workForOneDocument(s);
|
||||
res = workForOneDocument(s, true);
|
||||
if (res.fail()) {
|
||||
createBabiesError(resultBuilder, errorCounter, res);
|
||||
}
|
||||
}
|
||||
res.reset(); // With babies reporting is handled in the result body
|
||||
} else {
|
||||
res = workForOneDocument(value);
|
||||
res = workForOneDocument(value, false);
|
||||
}
|
||||
|
||||
auto resDocs = resultBuilder.steal();
|
||||
|
|
Loading…
Reference in New Issue