summaryrefslogtreecommitdiff
path: root/src/mongo/db/bson/dotted_path_support.cpp
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-14 14:26:38 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-14 14:26:38 -0300
commit294bc6ecabf14c09c9bc8644704921dcf97cb44e (patch)
tree279b1e0bab53901a1647ac63c1c724f0f789a663 /src/mongo/db/bson/dotted_path_support.cpp
parent70be7c27a251621187a1de533462ae2bb1e3bd39 (diff)
parent1e917fd798aa25b7066d4b414b51184f13d5a092 (diff)
Update upstream source from tag 'upstream/6.0.10'debian/6.0.10-1
Update to upstream version '6.0.10' with Debian dir 2d176fa254eee97b139f712fec5709641335a8c3
Diffstat (limited to 'src/mongo/db/bson/dotted_path_support.cpp')
-rw-r--r--src/mongo/db/bson/dotted_path_support.cpp104
1 files changed, 52 insertions, 52 deletions
diff --git a/src/mongo/db/bson/dotted_path_support.cpp b/src/mongo/db/bson/dotted_path_support.cpp
index 8bfc0483f3b..256b87d1630 100644
--- a/src/mongo/db/bson/dotted_path_support.cpp
+++ b/src/mongo/db/bson/dotted_path_support.cpp
@@ -54,70 +54,70 @@ void _extractAllElementsAlongPath(const BSONObj& obj,
bool expandArrayOnTrailingField,
BSONDepthIndex depth,
MultikeyComponents* arrayComponents) {
- BSONElement e = obj.getField(path);
-
- if (e.eoo()) {
- size_t idx = path.find('.');
- if (idx != std::string::npos) {
- invariant(depth != std::numeric_limits<BSONDepthIndex>::max());
- StringData left = path.substr(0, idx);
- StringData next = path.substr(idx + 1, path.size());
-
- BSONElement e = obj.getField(left);
-
- if (e.type() == Object) {
+ size_t idx = path.find('.');
+ if (idx != std::string::npos) {
+ invariant(depth != std::numeric_limits<BSONDepthIndex>::max());
+ StringData left = path.substr(0, idx);
+ StringData next = path.substr(idx + 1, path.size());
+
+ BSONElement e = obj.getField(left);
+
+ if (e.type() == Object) {
+ _extractAllElementsAlongPath(e.embeddedObject(),
+ next,
+ elements,
+ expandArrayOnTrailingField,
+ depth + 1,
+ arrayComponents);
+ } else if (e.type() == Array) {
+ bool allDigits = false;
+ if (next.size() > 0 && ctype::isDigit(next[0])) {
+ unsigned temp = 1;
+ while (temp < next.size() && ctype::isDigit(next[temp]))
+ temp++;
+ allDigits = temp == next.size() || next[temp] == '.';
+ }
+ if (allDigits) {
_extractAllElementsAlongPath(e.embeddedObject(),
next,
elements,
expandArrayOnTrailingField,
depth + 1,
arrayComponents);
- } else if (e.type() == Array) {
- bool allDigits = false;
- if (next.size() > 0 && ctype::isDigit(next[0])) {
- unsigned temp = 1;
- while (temp < next.size() && ctype::isDigit(next[temp]))
- temp++;
- allDigits = temp == next.size() || next[temp] == '.';
+ } else {
+ BSONObjIterator i(e.embeddedObject());
+ while (i.more()) {
+ BSONElement e2 = i.next();
+ if (e2.type() == Object || e2.type() == Array)
+ _extractAllElementsAlongPath(e2.embeddedObject(),
+ next,
+ elements,
+ expandArrayOnTrailingField,
+ depth + 1,
+ arrayComponents);
}
- if (allDigits) {
- _extractAllElementsAlongPath(e.embeddedObject(),
- next,
- elements,
- expandArrayOnTrailingField,
- depth + 1,
- arrayComponents);
- } else {
- BSONObjIterator i(e.embeddedObject());
- while (i.more()) {
- BSONElement e2 = i.next();
- if (e2.type() == Object || e2.type() == Array)
- _extractAllElementsAlongPath(e2.embeddedObject(),
- next,
- elements,
- expandArrayOnTrailingField,
- depth + 1,
- arrayComponents);
- }
- if (arrayComponents) {
- arrayComponents->insert(depth);
- }
+ if (arrayComponents) {
+ arrayComponents->insert(depth);
}
- } else {
- // do nothing: no match
}
+ } else {
+ // do nothing: no match
}
} else {
- if (e.type() == Array && expandArrayOnTrailingField) {
- BSONObjIterator i(e.embeddedObject());
- while (i.more()) {
- elements.insert(i.next());
- }
- if (arrayComponents) {
- arrayComponents->insert(depth);
+ BSONElement e = obj.getField(path);
+
+ if (e.ok()) {
+ if (e.type() == Array && expandArrayOnTrailingField) {
+ BSONObjIterator i(e.embeddedObject());
+ while (i.more()) {
+ elements.insert(i.next());
+ }
+ if (arrayComponents) {
+ arrayComponents->insert(depth);
+ }
+ } else {
+ elements.insert(e);
}
- } else {
- elements.insert(e);
}
}
}