mirror of https://gitee.com/bigwinds/arangodb
do not ignore document revision (#6852)
This commit is contained in:
parent
825dc54332
commit
801dd32dac
|
@ -212,8 +212,7 @@ bool RestDocumentHandler::readSingleDocument(bool generateBody) {
|
||||||
|
|
||||||
TRI_voc_rid_t ifRid = extractRevision("if-match", isValidRevision);
|
TRI_voc_rid_t ifRid = extractRevision("if-match", isValidRevision);
|
||||||
if (!isValidRevision) {
|
if (!isValidRevision) {
|
||||||
ifRid =
|
ifRid = UINT64_MAX; // an impossible rev, so precondition failed will happen
|
||||||
UINT64_MAX; // an impossible rev, so precondition failed will happen
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VPackBuilder builder;
|
VPackBuilder builder;
|
||||||
|
@ -382,14 +381,18 @@ bool RestDocumentHandler::modifyDocument(bool isPatch) {
|
||||||
// extract the revision, if single document variant and header given:
|
// extract the revision, if single document variant and header given:
|
||||||
std::shared_ptr<VPackBuilder> builder;
|
std::shared_ptr<VPackBuilder> builder;
|
||||||
if (!isArrayCase) {
|
if (!isArrayCase) {
|
||||||
TRI_voc_rid_t revision = 0;
|
|
||||||
bool isValidRevision;
|
bool isValidRevision;
|
||||||
revision = extractRevision("if-match", isValidRevision);
|
TRI_voc_rid_t headerRev = extractRevision("if-match", isValidRevision);
|
||||||
if (!isValidRevision) {
|
if (!isValidRevision) {
|
||||||
revision = UINT64_MAX; // an impossible revision, so precondition failed
|
headerRev = UINT64_MAX; // an impossible revision, so precondition failed
|
||||||
}
|
}
|
||||||
|
if (headerRev != 0) {
|
||||||
|
opOptions.ignoreRevs = false;
|
||||||
|
}
|
||||||
|
|
||||||
VPackSlice keyInBody = body.get(StaticStrings::KeyString);
|
VPackSlice keyInBody = body.get(StaticStrings::KeyString);
|
||||||
if ((revision != 0 && TRI_ExtractRevisionId(body) != revision) ||
|
TRI_voc_rid_t revInBody = TRI_ExtractRevisionId(body);
|
||||||
|
if ((headerRev != 0 && revInBody != headerRev) ||
|
||||||
keyInBody.isNone() || keyInBody.isNull() ||
|
keyInBody.isNone() || keyInBody.isNull() ||
|
||||||
(keyInBody.isString() && keyInBody.copyString() != key)) {
|
(keyInBody.isString() && keyInBody.copyString() != key)) {
|
||||||
// We need to rewrite the document with the given revision and key:
|
// We need to rewrite the document with the given revision and key:
|
||||||
|
@ -398,18 +401,19 @@ bool RestDocumentHandler::modifyDocument(bool isPatch) {
|
||||||
VPackObjectBuilder guard(builder.get());
|
VPackObjectBuilder guard(builder.get());
|
||||||
TRI_SanitizeObject(body, *builder);
|
TRI_SanitizeObject(body, *builder);
|
||||||
builder->add(StaticStrings::KeyString, VPackValue(key));
|
builder->add(StaticStrings::KeyString, VPackValue(key));
|
||||||
if (revision != 0) {
|
if (headerRev != 0) {
|
||||||
builder->add(StaticStrings::RevString,
|
builder->add(StaticStrings::RevString,
|
||||||
VPackValue(TRI_RidToString(revision)));
|
VPackValue(TRI_RidToString(headerRev)));
|
||||||
|
} else if (!opOptions.ignoreRevs && revInBody != 0) {
|
||||||
|
builder->add(StaticStrings::RevString,
|
||||||
|
VPackValue(TRI_RidToString(headerRev)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body = builder->slice();
|
body = builder->slice();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (revision != 0) {
|
|
||||||
opOptions.ignoreRevs = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// find and load collection given by name or identifier
|
// find and load collection given by name or identifier
|
||||||
|
|
Loading…
Reference in New Issue