8000 Bug fix/issue 11275 (#11299) · arangodb/arangodb@302578a · GitHub
[go: up one dir, main page]

Skip to content

Commit 302578a

Browse files
authored
Bug fix/issue 11275 (#11299)
* fixed issue #11275 * added test, fixed it * fix CHANGELOG entry
1 parent e6e955b commit 302578a

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
devel
22
-----
33

4+
* Fixed issue #11275: indexes backward compatibility broken in 3.5+.
5+
46
* Updated snowball dependency to the latest version.
57
More stemmers are available. Built-in analyzer list is unchanged.
68

arangod/RocksDBEngine/RocksDBVPackIndex.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,23 @@ namespace {
751751
std::vector<arangodb::basics::AttributeName>::const_iterator begin,
752752
std::vector<arangodb::basics::AttributeName>::const_iterator end) {
753753
for (; begin != end; ++begin) {
754+
// check if, after fetching the subattribute, we are point to a non-object.
755+
// e.g. if the index is on field ["a.b"], the first iteration of this loop
756+
// will look for subattribute "a" in the original document. this will always
757+
// work. however, when looking for "b", we have to make sure that "a" was
758+
// an object. otherwise we must not call Slice::get() on it. In case one of
759+
// the subattributes we found so far is not an object, we fall back to the
760+
// regular comparison
761+
if (!first.isObject() || !second.isObject()) {
762+
break;
763+
}
764+
754765
// fetch subattribute
755766
first = first.get(begin->name);
756-
second = second.get(begin->name);
757767
if (first.isExternal()) {
758768
first = first.resolveExternal();
759769
}
770+
second = second.get(begin->name);
760771
if (second.isExternal()) {
761772
second = second.resolveExternal();
762773
}

tests/js/common/shell/shell-hash-index.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*jshint globalstrict:false, strict:false */
2-
/*global fail, assertEqual, assertTrue, assertFalse, assertNotEqual */
2+
/*global fail, assertEqual, assertTrue, assertFalse, assertNull, assertNotEqual */
33

44
////////////////////////////////////////////////////////////////////////////////
55
/// @brief test the hash index
@@ -604,7 +604,25 @@ function HashIndexSuite() {
604604
}
605605
i *= 2;
606606
}
607-
}
607+
},
608+
609+
testUniqueIndexNullSubattribute : function () {
610+
let idx = collection.ensureIndex({ type: "hash", unique: true, fields: ["a.b"] });
611+
612+
assertEqual("hash", idx.type);
613+
assertEqual(true, idx.unique);
614+
assertEqual(["a.b"], idx.fields);
615+
assertEqual(true, idx.isNewlyCreated);
616+
617+
// as "a" is null here, "a.b" should also be null, at least it should not fail when accessing it via the index
618+
collection.insert({ _key: "test", a : null });
619+
collection.update("test", { something: "test2" });
620+
621+
let doc = collection.document("test");
622+
assertNull(doc.a);
623+
assertEqual("test2", doc.something);
624+
},
625+
608626
};
609627
}
610628

0 commit comments

Comments
 (0)
0