summaryrefslogtreecommitdiff
path: root/jstests/aggregation
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2015-03-11 17:45:49 -0400
committerEliot Horowitz <eliot@10gen.com>2015-03-11 17:46:44 -0400
commitf4d17dd81431f9724006c0837ccac44068971b1d (patch)
tree729b7d2035cb937a6bcfcf93c8e0730230a0b003 /jstests/aggregation
parentf931ac5fa8d69d1b3e08267cd47ba14e5b3b30e2 (diff)
downloadmongo-f4d17dd81431f9724006c0837ccac44068971b1d.tar.gz
SERVER-8088: $unwind of scalar should return 1 doc with scalar
Diffstat (limited to 'jstests/aggregation')
-rw-r--r--jstests/aggregation/unwind.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/jstests/aggregation/unwind.js b/jstests/aggregation/unwind.js
new file mode 100644
index 00000000000..d4c540436ae
--- /dev/null
+++ b/jstests/aggregation/unwind.js
@@ -0,0 +1,15 @@
+// SERVER-8088: test $unwind with a scalar
+
+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; }));