summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2015-03-10 18:12:38 -0400
committerEliot Horowitz <eliot@10gen.com>2015-03-11 16:22:41 -0400
commit25feddadeef43fb0668350b40282fcdfbb1f2296 (patch)
treecc2fbad35a5984b77921bd3a1d8c869821a45f12 /jstests
parente9761e50b5bb00b8a35f96b2ce7698b5eecd6ff8 (diff)
downloadmongo-25feddadeef43fb0668350b40282fcdfbb1f2296.tar.gz
SERVER-8008: $unwind of scalar should return 1 doc with scalar
Diffstat (limited to 'jstests')
-rw-r--r--jstests/aggregation/unwind.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/jstests/aggregation/unwind.js b/jstests/aggregation/unwind.js
new file mode 100644
index 00000000000..5271317fa3e
--- /dev/null
+++ b/jstests/aggregation/unwind.js
@@ -0,0 +1,13 @@
+t = db.agg_unwind;
+t.drop();
+
+t.insert( {_id : 1 } );
+t.insert( {_id : 2, x : null } );
+t.insert( {_id : 3, x : [] } );
+t.insert( {_id : 4, x : [1, 2] } );
+t.insert( {_id : 5, x : [3] } );
+t.insert( {_id : 6, x : 4 } );
+
+var res = t.aggregate( [ { $unwind : "$x" }, { $sort : { _id : 1 } } ] ).toArray();
+assert.eq(4, res.length);
+assert.eq([1,2,3,4],res.map(function(z){ return z.x; }));