summaryrefslogtreecommitdiff
path: root/jstests/core/slice1.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/slice1.js')
-rw-r--r--jstests/core/slice1.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/jstests/core/slice1.js b/jstests/core/slice1.js
index ac1773f0f0a..72e60698975 100644
--- a/jstests/core/slice1.js
+++ b/jstests/core/slice1.js
@@ -263,6 +263,12 @@ testSingleDocument({'a.b.c': {$slice: 1}, d: 0},
{a: [[[{b: [[[{c: [1, 2, 3]}]]]}]]], d: 456},
{a: [[[{b: [[[{c: [1, 2, 3]}]]]}]]]});
+// Test that even though $slice cannot be applied to deep arrays, fields are still filtered in the
+// objects inside these deep arrays for inclusion projections.
+testSingleDocument({e: 1, 'a.b': {$slice: 1}},
+ {e: 123, a: [[[{b: [1, 2, 3], d: 4, f: 5}]]]},
+ {e: 123, a: [[[{b: [1, 2, 3]}]]]});
+
// Test $slice with an inclusion/exclusion projection for _id field.
testSingleDocument({_id: 1, a: {$slice: [1, 1]}},
{_id: 123, a: [1, 2, 3]},