8000 Bug fix/issue 11275 by jsteemann · Pull Request #11299 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Bug fix/issue 11275 #11299

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 5 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added test, fixed it
  • Loading branch information
jsteemann committed Mar 18, 2020
commit 88d30d0f84f37dce5e440b5802a4b46726e0f322
25 changes: 11 additions & 14 deletions arangod/RocksDBEngine/RocksDBVPackIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,10 +750,18 @@ namespace {
bool attributesEqual(VPackSlice first, VPackSlice second,
std::vector<arangodb::basics::AttributeName>::const_iterator begin,
std::vector<arangodb::basics::AttributeName>::const_iterator end) {
TRI_ASSERT(first.isObject());
TRI_ASSERT(second.isObject());

for (; begin != end; ++begin) {
// check if, after fetching the subattribute, we are point to a non-object.
// e.g. if the index is on field ["a.b"], the first iteration of this loop
// will look for subattribute "a" in the original document. this will always
// work. however, when looking for "b", we have to make sure that "a" was
// an object. otherwise we must not call Slice::get() on it. In case one of
// the subattributes we found so far is not an object, we fall back to the
// regular comparison
if (!first.isObject() || !second.isObject()) {
break;
}

// fetch subattribute
first = first.get(begin->name);
if (first.isExternal()) {
Expand Down Expand Up @@ -787,17 +795,6 @@ namespace {
if (notF1 || notF2) { // one of the paths was not found
break;
}

// check if, after fetching the subattribute, we are point to a non-object.
// e.g. if the index is on field ["a.b"], the first iteration of this loop
// will look for subattribute "a" in the original document. this will always
// work. however, when looking for "b", we have to make sure that "a" was
// an object. otherwise we must not call Slice::get() on it. In case one of
// the subattributes we found so far is not an object, we fall back to the
// regular comparison
if (!first.isObject() || !second.isObject()) {
break;
}
}

return basics::VelocyPackHelper::equal(first, second, true);
Expand Down
22 changes: 20 additions & 2 deletions tests/js/common/shell/shell-hash-index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*jshint globalstrict:false, strict:false */
/*global fail, assertEqual, assertTrue, assertFalse, assertNotEqual */
/*global fail, assertEqual, assertTrue, assertFalse, assertNull, assertNotEqual */

///////////////////////////////////////////////////////////////////////////// 8C13 ///
/// @brief test the hash index
Expand Down Expand Up @@ -604,7 +604,25 @@ function HashIndexSuite() {
}
i *= 2;
}
}
},

testUniqueIndexNullSubattribute : function () {
let idx = collection.ensureIndex({ type: "hash", unique: true, fields: ["a.b"] });

assertEqual("hash", idx.type);
assertEqual(true, idx.unique);
assertEqual(["a.b"], idx.fields);
assertEqual(true, idx.isNewlyCreated);

// as "a" is null here, "a.b" should also be null, at least it should not fail when accessing it via the index
collection.insert({ _key: "test", a : null });
collection.update("test", { something: "test2" });

let doc = collection.document("test");
assertNull(doc.a);
assertEqual("test2", doc.something);
},

};
}

Expand Down
0