8000 3.5 -- DEVSUP-492 by ObiWahn · Pull Request #10402 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

3.5 -- DEVSUP-492 #10402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
5 changes: 2 additions & 3 deletions arangod/Aql/Ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down
33 changes: 33 additions & 0 deletions tests/js/server/aql/aql-modify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
0