diff --git a/HISTORY b/HISTORY index 72e30624628..453192e514a 100644 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,5 @@ -1.1.12 ------------------ +1.2 2012-11-27 +-------------- - Honor connectTimeoutMS option for replicasets (Issue #750, https://github.com/aheckmann) - Fix ping strategy regression (Issue #738, https://github.com/aheckmann) - Small cleanup of code (Issue #753, https://github.com/sokra/node-mongodb-native) @@ -13,6 +13,7 @@ - new MongoClient introduced as the point of connecting to MongoDB's instead of the Db - open/close/db/connect methods implemented - Implemented common URL connection format using MongoClient.connect allowing for simialar interface across all drivers. +- Fixed a bug with aggregation helper not properly accepting readPreference 1.1.11 2012-10-10 ----------------- diff --git a/test/aggregation_framework_test.js b/test/aggregation_framework_test.js index fd2f8904369..bc850709425 100644 --- a/test/aggregation_framework_test.js +++ b/test/aggregation_framework_test.js @@ -274,6 +274,76 @@ exports.shouldCorrectlyFailAndReturnError = function(test) { }); } +/** + * @ignore + */ +exports.shouldCorrectlyPassReadPreference = function(test) { + // Some docs for insertion + var docs = [{ + title : "this is my title", author : "bob", posted : new Date() , + pageViews : 5, tags : [ "fun" , "good" , "fun" ], other : { foo : 5 }, + comments : [ + { author :"joe", text : "this is cool" }, { author :"sam", text : "this is bad" } + ]}]; + + client.admin().serverInfo(function(err, result){ + if(parseInt((result.version.replace(/\./g, ''))) >= 210) { + // Create a collection + client.createCollection('shouldCorrectlyFailAndReturnError', function(err, collection) { + // Override the command object for the db + var _command = client.command; + client.command = function(selector, options, callback) { + var args = Array.prototype.slice.call(arguments, 0); + test.equal("secondary", options.readPreference); + _command.apply(client, args); + } + + // Insert the docs + collection.insert(docs, {w: 1}, function(err, result) { + // Execute aggregate + collection.aggregate( + { $project : { + author : 1, + tags : 1, + }}, + { $32unwind : "$tags" }, + { $group : { + _id : { tags : 1 }, + authors : { $addToSet : "$author" } + }}, + {readPreference:'secondary'} + , function(err, result) { + // client.command = _command; + + // Execute aggregate + collection.aggregate( + [{ $project : { + author : 1, + tags : 1, + }}, + { $32unwind : "$tags" }, + { $group : { + _id : { tags : 1 }, + authors : { $addToSet : "$author" } + }}], + {readPreference:'secondary'} + , function(err, result) { + client.command = _command; + test.ok(err != null); + test.done(); + }); + + test.ok(err != null); + test.done(); + }); + }); + }); + } else { + test.done(); + } + }); +} + // /** // * @ignore // */