1
0
Fork 0
This commit is contained in:
Jan Christoph Uhde 2019-11-12 20:30:58 +01:00 committed by KVS85
parent 3a0ed2f8b9
commit 413a81fba9
3 changed files with 49 additions and 3 deletions

View File

@ -1,6 +1,20 @@
v3.5.3 (XXXX-XX-XX)
-------------------
* Fixed UPSERT matching.
Empty objects in the `UPSERT { ... }` expression will not be omitted anymore:
db._collection("col").insert({ "find" : "me" });
db._query(` UPSERT { "find" : "me", "foo" : {} }
UPDATE { "foo" : "not gonna happen" }
INSERT { "find" : "me", "foo" : {} }
INTO col
`)
This will now correctly insert a document instead of updating the existing,
that only partially machtes the upsert-expression.
* Fixed undefined behaviour with creation of ArangoSearch links with custom
analyzers in cluster environment.

View File

@ -2665,7 +2665,6 @@ AstNode* Ast::makeConditionFromExample(AstNode const* node) {
TRI_ASSERT(object->type == NODE_TYPE_OBJECT);
auto const n = object->numMembers();
for (size_t i = 0; i < n; ++i) {
auto member = object->getMember(i);
@ -2680,8 +2679,8 @@ AstNode* Ast::makeConditionFromExample(AstNode const* node) {
auto value = member->getMember(0);
if (value->type == NODE_TYPE_OBJECT) {
createCondition(value);
if (value->type == NODE_TYPE_OBJECT && value->numMembers() != 0) {
createCondition(value);
} else {
auto access = variable;
for (auto const& it : attributeParts) {

View File

@ -1127,6 +1127,39 @@ function aqlUpsertOptionsSuite() {
validateDocsAreUpdated(docs, invalid, true);
},
testUpsertEmptyObject: function () {
let NEW, OLD, res;
col.insert({ "value1": "find me" });
// before "find me" was found because the empty object
// was ignored now we will insert instead
let q1 = `UPSERT { "value1" : "find me", "value2" : {} }
INSERT { "value1" : "find me", "value2" : {} }
UPDATE { "value1" : "not gonna happen" }
IN ${collectionName}
RETURN [$OLD, $NEW]`;
res = db._query(q1).toArray();
OLD = res[0][0];
NEW = res[0][1];
assertEqual(NEW.value1, "find me");
assertEqual(NEW.value2, {});
// now we update the exact doucment
let q2 = `UPSERT { "value1" : "find me", "value2" : {} }
INSERT { "value1" : "not gonna happen" }
UPDATE { "value1" : "update" }
IN ${collectionName}
RETURN [$OLD, $NEW]`;
res = db._query(q2).toArray();
OLD = res[0][0];
NEW = res[0][1];
assertEqual(NEW.value1, "update");
assertEqual(NEW.value2, {});
},
/* We cannot yet solve this. If you need to ensure _rev value checks put them in the UPDATE {} clause
testUpsertSingleWithInvalidRevInMatch : function () {
const invalid = genInvalidValue();