diff options
Diffstat (limited to 'jstests/aggregation/bugs/server3832.js')
-rw-r--r-- | jstests/aggregation/bugs/server3832.js | 73 |
1 files changed, 20 insertions, 53 deletions
diff --git a/jstests/aggregation/bugs/server3832.js b/jstests/aggregation/bugs/server3832.js index c5bdf27e36e..b2c59ccd244 100644 --- a/jstests/aggregation/bugs/server3832.js +++ b/jstests/aggregation/bugs/server3832.js @@ -1,89 +1,56 @@ var s3832 = db.c; s3832.drop(); -s3832.save({_id: 1, a:"foo", b:"bar"}); -s3832.save({_id: 2, a:"feh", b:"baz"}); -s3832.save({_id: 3, a:"fee", b:"fum"}); - -var a1 = s3832.aggregate( { $match : { b : "baz" } } ); - -var a1result = [ - { - "_id" : 2, - "a" : "feh", - "b" : "baz" - } -]; +s3832.save({_id: 1, a: "foo", b: "bar"}); +s3832.save({_id: 2, a: "feh", b: "baz"}); +s3832.save({_id: 3, a: "fee", b: "fum"}); -assert.eq(a1.toArray(), a1result, 's3832.a1 failed'); +var a1 = s3832.aggregate({$match: {b: "baz"}}); + +var a1result = [{"_id": 2, "a": "feh", "b": "baz"}]; +assert.eq(a1.toArray(), a1result, 's3832.a1 failed'); -var a2 = s3832.aggregate( { $sort : { a : 1 } } ); +var a2 = s3832.aggregate({$sort: {a: 1}}); var a2result = [ - { - "_id" : 3, - "a" : "fee", - "b" : "fum" - }, - { - "_id" : 2, - "a" : "feh", - "b" : "baz" - }, - { - "_id" : 1, - "a" : "foo", - "b" : "bar" - } + {"_id": 3, "a": "fee", "b": "fum"}, + {"_id": 2, "a": "feh", "b": "baz"}, + {"_id": 1, "a": "foo", "b": "bar"} ]; assert.eq(a2.toArray(), a2result, 's3832.a2 failed'); - -var a3 = s3832.aggregate( - { $match : { b : "baz" } }, - { $sort : { a : 1 } } ); +var a3 = s3832.aggregate({$match: {b: "baz"}}, {$sort: {a: 1}}); assert.eq(a3.toArray(), a1result, 's3832.a3 failed'); +db.s3832.ensureIndex({b: 1}, {name: "s3832_b"}); -db.s3832.ensureIndex({ b : 1 }, { name : "s3832_b" }); - - -var a4 = s3832.aggregate({ $match : { b : "baz" } }); +var a4 = s3832.aggregate({$match: {b: "baz"}}); assert.eq(a4.toArray(), a1result, 's3832.a4 failed'); - -var a5 = s3832.aggregate({ $sort : { a : 1 } }); +var a5 = s3832.aggregate({$sort: {a: 1}}); assert.eq(a5.toArray(), a2result, 's3832.a5 failed'); - -var a6 = s3832.aggregate( - { $match : { b : "baz" } }, - { $sort : { a : 1 } } ); +var a6 = s3832.aggregate({$match: {b: "baz"}}, {$sort: {a: 1}}); assert.eq(a6.toArray(), a1result, 's3832.a6 failed'); - var dropb = db.s3832.dropIndex("s3832_b"); -db.s3832.ensureIndex({ a : 1 }, { name : "s3832_a" }); +db.s3832.ensureIndex({a: 1}, {name: "s3832_a"}); -var a7 = s3832.aggregate({ $match : { b : "baz" } }); +var a7 = s3832.aggregate({$match: {b: "baz"}}); assert.eq(a7.toArray(), a1result, 's3832.a7 failed'); - -var a8 = s3832.aggregate({ $sort : { a : 1 } }); +var a8 = s3832.aggregate({$sort: {a: 1}}); assert.eq(a8.toArray(), a2result, 's3832.a8 failed'); - -var a9 = s3832.aggregate( - { $match : { b : "baz" } }, - { $sort : { a : 1 } } ); +var a9 = s3832.aggregate({$match: {b: "baz"}}, {$sort: {a: 1}}); assert.eq(a9.toArray(), a1result, 's3832.a9 failed'); |