-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NODE-800 Added promoteValues flag (default to true) to allow user to …
…specify they only want wrapped BSON values back instead of promotion to native types.
- Loading branch information
Showing
10 changed files
with
132 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
exports['should correctly honor promoteValues when creating an instance using Db'] = { | ||
// Add a tag that our runner can trigger on | ||
// in this case we are setting that node needs to be higher than 0.10.X to run | ||
metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, | ||
|
||
// The actual test we wish to run | ||
test: function(configuration, test) { | ||
var Long = configuration.require.Long, | ||
Int32 = configuration.require.Int32, | ||
Double = configuration.require.Double; | ||
|
||
var o = configuration.writeConcernMax(); | ||
var db = configuration.newDbInstance(o, {native_parser:true, promoteValues: false}) | ||
db.open(function(err, db) { | ||
db.collection('shouldCorrectlyHonorPromoteValues').insert({ | ||
doc: Long.fromNumber(10) | ||
, int: 10 | ||
, double: 2.2222 | ||
, array: [[Long.fromNumber(10)]] | ||
}, function(err, doc) { | ||
test.equal(null, err); | ||
|
||
db.collection('shouldCorrectlyHonorPromoteValues').findOne(function(err, doc) { | ||
test.equal(null, err); | ||
|
||
test.deepEqual(Long.fromNumber(10), doc.doc); | ||
test.deepEqual(new Int32(10), doc.int); | ||
test.deepEqual(new Double(2.2222), doc.double); | ||
|
||
db.close(); | ||
test.done(); | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
exports['should correctly honor promoteValues when creating an instance using MongoClient'] = { | ||
// Add a tag that our runner can trigger on | ||
// in this case we are setting that node needs to be higher than 0.10.X to run | ||
metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, | ||
|
||
// The actual test we wish to run | ||
test: function(configuration, test) { | ||
var Long = configuration.require.Long, | ||
Int32 = configuration.require.Int32, | ||
Double = configuration.require.Double, | ||
MongoClient = configuration.require.MongoClient; | ||
|
||
MongoClient.connect(configuration.url(), { | ||
promoteValues: false, | ||
}, function(err, db) { | ||
db.collection('shouldCorrectlyHonorPromoteValues').insert({ | ||
doc: Long.fromNumber(10) | ||
, int: 10 | ||
, double: 2.2222 | ||
, array: [[Long.fromNumber(10)]] | ||
}, function(err, doc) { | ||
test.equal(null, err); | ||
|
||
db.collection('shouldCorrectlyHonorPromoteValues').findOne(function(err, doc) { | ||
test.equal(null, err); | ||
|
||
test.deepEqual(Long.fromNumber(10), doc.doc); | ||
test.deepEqual(new Int32(10), doc.int); | ||
test.deepEqual(new Double(2.2222), doc.double); | ||
|
||
db.close(); | ||
test.done(); | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
exports['should correctly honor promoteValues at cursor level'] = { | ||
// Add a tag that our runner can trigger on | ||
// in this case we are setting that node needs to be higher than 0.10.X to run | ||
metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, | ||
|
||
// The actual test we wish to run | ||
test: function(configuration, test) { | ||
var Long = configuration.require.Long, | ||
Int32 = configuration.require.Int32, | ||
Double = configuration.require.Double, | ||
MongoClient = configuration.require.MongoClient; | ||
|
||
MongoClient.connect(configuration.url(), { | ||
promoteValues: false, | ||
}, function(err, db) { | ||
db.collection('shouldCorrectlyHonorPromoteValues').insert({ | ||
doc: Long.fromNumber(10) | ||
, int: 10 | ||
, double: 2.2222 | ||
, array: [[Long.fromNumber(10)]] | ||
}, function(err, doc) { | ||
test.equal(null, err); | ||
|
||
db.collection('shouldCorrectlyHonorPromoteValues').find().next(function(err, doc) { | ||
test.equal(null, err); | ||
|
||
test.deepEqual(Long.fromNumber(10), doc.doc); | ||
test.deepEqual(new Int32(10), doc.int); | ||
test.deepEqual(new Double(2.2222), doc.double); | ||
|
||
db.close(); | ||
test.done(); | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters