8000 Bug fix 3.6/issue 11275 (#11298) · arangodb/arangodb@5b5b929 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5b5b929

Browse files
jsteemannKVS85
andauthored
Bug fix 3.6/issue 11275 (#11298)
* fixed issue #11275 * added test, fixed it Co-authored-by: KVS85 <vadim@arangodb.com>
1 parent d99395c commit 5b5b929

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
v3.6.3 (XXXX-XX-XX)
22
-------------------
33

4+
* Fixed issue #11275: indexes backward compatibility broken in 3.5+.
5+
46
* Fix an endless loop in FollowerInfo::persistInAgency which could trigger a
57
hanger if a collection was dropped at the wrong time.
68

arangod/RocksDBEngine/RocksDBVPackIndex.cpp

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

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