Skip to content

Commit 7553638

Browse files
committed
ensure promoteBuffers is propegated in same fashion as promoteValues and promoteLongs
1 parent f846581 commit 7553638

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

lib/collection.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ var Collection = function(db, topology, dbName, name, pkFactory, options) {
6666
var serializeFunctions = options == null || options.serializeFunctions == null ? db.s.options.serializeFunctions : options.serializeFunctions;
6767
var raw = options == null || options.raw == null ? db.s.options.raw : options.raw;
6868
var promoteLongs = options == null || options.promoteLongs == null ? db.s.options.promoteLongs : options.promoteLongs;
69-
var promoteValues = options == null || options.raw == promoteValues ? db.s.options.promoteValues : options.promoteValues;
69+
var promoteValues = options == null || options.promoteValues == null ? db.s.options.promoteValues : options.promoteValues;
70+
var promoteBuffers = options == null || options.promoteBuffers == null ? db.s.options.promoteBuffers : options.promoteBuffers;
7071
var readPreference = null;
7172
var collectionHint = null;
7273
var namespace = f("%s.%s", dbName, name);
@@ -118,6 +119,8 @@ var Collection = function(db, topology, dbName, name, pkFactory, options) {
118119
, promoteLongs: promoteLongs
119120
// promoteValues
120121
, promoteValues: promoteValues
122+
// promoteBuffers
123+
, promoteBuffers: promoteBuffers
121124
// internalHint
122125
, internalHint: internalHint
123126
// collectionHint
@@ -351,6 +354,7 @@ Collection.prototype.find = function() {
351354
// Set promoteLongs if available at collection level
352355
if(newOptions.promoteLongs == null && typeof this.s.promoteLongs == 'boolean') newOptions.promoteLongs = this.s.promoteLongs;
353356
if(newOptions.promoteValues == null && typeof this.s.promoteValues == 'boolean') newOptions.promoteValues = this.s.promoteValues;
357+
if(newOptions.promoteBuffers == null && typeof this.s.promoteBuffers == 'boolean') newOptions.promoteBuffers = this.s.promoteBuffers;
354358

355359
// Sort options
356360
if(findCommand.sort) {
@@ -1364,6 +1368,7 @@ define.classMethod('save', {callback: true, promise:true});
13641368
* @param {boolean} [options.raw=false] Return document results as raw BSON buffers.
13651369
* @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution.
13661370
* @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types.
1371+
* @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers.
13671372
* @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
13681373
* @param {boolean} [options.partial=false] Specify if the cursor should return partial results when querying against a sharded system
13691374
* @param {number} [options.maxTimeMS=null] Number of miliseconds to wait before aborting the query.
@@ -2558,6 +2563,7 @@ function decorateWithCollation(command, self, options) {
25582563
* @param {boolean} [options.raw=false] Return document results as raw BSON buffers.
25592564
* @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution.
25602565
* @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types.
2566+
* @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers.
25612567
* @param {Collection~resultCallback} callback The command result callback
25622568
* @return {(null|AggregationCursor)}
25632569
*/

lib/db.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var EventEmitter = require('events').EventEmitter
2424
, assign = require('./utils').assign;
2525

2626
var debugFields = ['authSource', 'w', 'wtimeout', 'j', 'native_parser', 'forceServerObjectId'
27-
, 'serializeFunctions', 'raw', 'promoteLongs', 'promoteValues', 'bufferMaxEntries', 'numberOfRetries', 'retryMiliSeconds'
27+
, 'serializeFunctions', 'raw', 'promoteLongs', 'promoteValues', 'promoteBuffers', 'bufferMaxEntries', 'numberOfRetries', 'retryMiliSeconds'
2828
, 'readPreference', 'pkFactory', 'parentDb', 'promiseLibrary', 'noListener'];
2929

3030
/**
@@ -47,7 +47,7 @@ var debugFields = ['authSource', 'w', 'wtimeout', 'j', 'native_parser', 'forceSe
4747
var legalOptionNames = ['w', 'wtimeout', 'fsync', 'j', 'readPreference', 'readPreferenceTags', 'native_parser'
4848
, 'forceServerObjectId', 'pkFactory', 'serializeFunctions', 'raw', 'bufferMaxEntries', 'authSource'
4949
, 'ignoreUndefined', 'promoteLongs', 'promiseLibrary', 'readConcern', 'retryMiliSeconds', 'numberOfRetries'
50-
, 'parentDb', 'noListener', 'loggerLevel', 'logger'];
50+
, 'parentDb', 'noListener', 'loggerLevel', 'logger', 'promoteBuffers', 'promoteLongs', 'promoteValues'];
5151

5252
/**
5353
* Creates a new Db instance
@@ -64,6 +64,7 @@ var legalOptionNames = ['w', 'wtimeout', 'fsync', 'j', 'readPreference', 'readPr
6464
* @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
6565
* @param {boolean} [options.raw=false] Return document results as raw BSON buffers.
6666
* @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution.
67+
* @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers.
6768
* @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types.
6869
* @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited.
6970
* @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).

lib/mongos.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var release = os.release();
5454
, 'store', 'auto_reconnect', 'autoReconnect', 'emitError'
5555
, 'keepAlive', 'noDelay', 'connectTimeoutMS', 'socketTimeoutMS'
5656
, 'loggerLevel', 'logger', 'reconnectTries', 'appname', 'domainsEnabled'
57-
, 'servername', 'promoteLongs', 'promoteValues'];
57+
, 'servername', 'promoteLongs', 'promoteValues', 'promoteBuffers'];
5858

5959
/**
6060
* Creates a new Mongos instance

lib/replset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var legalOptionNames = ['ha', 'haInterval', 'replicaSet', 'rs_name', 'secondaryA
4949
, 'store', 'auto_reconnect', 'autoReconnect', 'emitError'
5050
, 'keepAlive', 'noDelay', 'connectTimeoutMS', 'socketTimeoutMS', 'strategy', 'debug'
5151
, 'loggerLevel', 'logger', 'reconnectTries', 'appname', 'domainsEnabled'
52-
, 'servername', 'promoteLongs', 'promoteValues'];
52+
, 'servername', 'promoteLongs', 'promoteValues', 'promoteBuffers'];
5353

5454
// Get package.json variable
5555
var driverVersion = require(__dirname + '/../package.json').version;

lib/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var release = os.release();
5151
, 'keepAlive', 'noDelay', 'connectTimeoutMS', 'socketTimeoutMS'
5252
, 'loggerLevel', 'logger', 'reconnectTries', 'reconnectInterval', 'monitoring'
5353
, 'appname', 'domainsEnabled'
54-
, 'servername', 'promoteLongs', 'promoteValues'];
54+
, 'servername', 'promoteLongs', 'promoteValues', 'promoteBuffers'];
5555

5656
/**
5757
* Creates a new Server instance

test/runner.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ var testFiles = [
301301
, '/test/functional/hang_tests.js',
302302
, '/test/functional/disconnect_handler_tests.js',
303303
, '/test/functional/promote_values_tests.js',
304+
, '/test/functional/promote_buffers_tests.js',
304305

305306
// Replicaset tests
306307
, '/test/functional/replset_read_preference_tests.js'

0 commit comments

Comments
 (0)