diff --git a/src/bson.ts b/src/bson.ts index 2af80efb71e..1abd2e70409 100644 --- a/src/bson.ts +++ b/src/bson.ts @@ -1,3 +1,4 @@ +import type { OperationParent } from './operations/command'; // import type * as _BSON from 'bson'; // let BSON: typeof _BSON = require('bson'); // try { @@ -69,3 +70,25 @@ export function pluckBSONSerializeOptions(options: BSONSerializeOptions): BSONSe raw }; } + +/** + * Merge the given BSONSerializeOptions, preferring options over the parent's options, and + * substituting defaults for values not set. + * + * @internal + */ +export function resolveBSONOptions( + options?: BSONSerializeOptions, + parent?: OperationParent +): BSONSerializeOptions { + const parentOptions = parent?.bsonOptions; + return { + raw: options?.raw ?? parentOptions?.raw ?? false, + promoteLongs: options?.promoteLongs ?? parentOptions?.promoteLongs ?? true, + promoteValues: options?.promoteValues ?? parentOptions?.promoteValues ?? true, + promoteBuffers: options?.promoteBuffers ?? parentOptions?.promoteBuffers ?? false, + ignoreUndefined: options?.ignoreUndefined ?? parentOptions?.ignoreUndefined ?? false, + serializeFunctions: options?.serializeFunctions ?? parentOptions?.serializeFunctions ?? false, + fieldsAsRaw: options?.fieldsAsRaw ?? parentOptions?.fieldsAsRaw ?? {} + }; +} diff --git a/src/collection.ts b/src/collection.ts index 7dacd0e07e5..e59474fb28f 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -8,7 +8,7 @@ import { MongoDBNamespace, Callback } from './utils'; -import { ObjectId, Document, BSONSerializeOptions } from './bson'; +import { ObjectId, Document, BSONSerializeOptions, resolveBSONOptions } from './bson'; import { MongoError } from './error'; import { UnorderedBulkOperation } from './bulk/unordered'; import { OrderedBulkOperation } from './bulk/ordered'; @@ -126,13 +126,8 @@ export interface CollectionPrivate { options: any; namespace: MongoDBNamespace; readPreference?: ReadPreference; + bsonOptions: BSONSerializeOptions; slaveOk?: boolean; - serializeFunctions?: boolean; - raw?: boolean; - promoteLongs?: boolean; - promoteValues?: boolean; - promoteBuffers?: boolean; - ignoreUndefined?: boolean; collectionHint?: Hint; readConcern?: ReadConcern; writeConcern?: WriteConcern; @@ -188,30 +183,10 @@ export class Collection implements OperationParent { } }, readPreference: ReadPreference.fromOptions(options), + bsonOptions: resolveBSONOptions(options, db), readConcern: ReadConcern.fromOptions(options), writeConcern: WriteConcern.fromOptions(options), - slaveOk: options == null || options.slaveOk == null ? db.slaveOk : options.slaveOk, - serializeFunctions: - options == null || options.serializeFunctions == null - ? db.s.options?.serializeFunctions - : options.serializeFunctions, - raw: options == null || options.raw == null ? db.s.options?.raw : options.raw, - promoteLongs: - options == null || options.promoteLongs == null - ? db.s.options?.promoteLongs - : options.promoteLongs, - promoteValues: - options == null || options.promoteValues == null - ? db.s.options?.promoteValues - : options.promoteValues, - promoteBuffers: - options == null || options.promoteBuffers == null - ? db.s.options?.promoteBuffers - : options.promoteBuffers, - ignoreUndefined: - options == null || options.ignoreUndefined == null - ? db.s.options?.ignoreUndefined - : options.ignoreUndefined + slaveOk: options == null || options.slaveOk == null ? db.slaveOk : options.slaveOk }; } @@ -260,6 +235,10 @@ export class Collection implements OperationParent { return this.s.readPreference; } + get bsonOptions(): BSONSerializeOptions { + return this.s.bsonOptions; + } + /** * The current writeConcern of the collection. If not explicitly defined for * this collection, will be inherited from the parent DB @@ -301,12 +280,6 @@ export class Collection implements OperationParent { if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // Add ignoreUndefined - if (this.s.options.ignoreUndefined) { - options = Object.assign({}, options); - options.ignoreUndefined = this.s.options.ignoreUndefined; - } - return executeOperation(this.s.topology, new InsertOneOperation(this, doc, options), callback); } @@ -428,12 +401,6 @@ export class Collection implements OperationParent { if (typeof options === 'function') (callback = options), (options = {}); options = Object.assign({}, options); - // Add ignoreUndefined - if (this.s.options.ignoreUndefined) { - options = Object.assign({}, options); - options.ignoreUndefined = this.s.options.ignoreUndefined; - } - return executeOperation( this.s.topology, new UpdateOneOperation(this, filter, update, options), @@ -471,12 +438,6 @@ export class Collection implements OperationParent { if (typeof options === 'function') (callback = options), (options = {}); options = Object.assign({}, options); - // Add ignoreUndefined - if (this.s.options.ignoreUndefined) { - options = Object.assign({}, options); - options.ignoreUndefined = this.s.options.ignoreUndefined; - } - return executeOperation( this.s.topology, new ReplaceOneOperation(this, filter, replacement, options), @@ -510,12 +471,6 @@ export class Collection implements OperationParent { if (typeof options === 'function') (callback = options), (options = {}); options = Object.assign({}, options); - // Add ignoreUndefined - if (this.s.options.ignoreUndefined) { - options = Object.assign({}, options); - options.ignoreUndefined = this.s.options.ignoreUndefined; - } - return executeOperation( this.s.topology, new UpdateManyOperation(this, filter, update, options), @@ -542,12 +497,6 @@ export class Collection implements OperationParent { if (typeof options === 'function') (callback = options), (options = {}); options = Object.assign({}, options); - // Add ignoreUndefined - if (this.s.options.ignoreUndefined) { - options = Object.assign({}, options); - options.ignoreUndefined = this.s.options.ignoreUndefined; - } - return executeOperation( this.s.topology, new DeleteOneOperation(this, filter, options), @@ -586,12 +535,6 @@ export class Collection implements OperationParent { options = Object.assign({}, options); - // Add ignoreUndefined - if (this.s.options.ignoreUndefined) { - options = Object.assign({}, options); - options.ignoreUndefined = this.s.options.ignoreUndefined; - } - return executeOperation( this.s.topology, new DeleteManyOperation(this, filter, options), @@ -1344,7 +1287,7 @@ export class Collection implements OperationParent { options = options || {}; // Give function's options precedence over session options. if (options.ignoreUndefined == null) { - options.ignoreUndefined = this.s.options.ignoreUndefined; + options.ignoreUndefined = this.bsonOptions.ignoreUndefined; } return new UnorderedBulkOperation(this, options); @@ -1355,7 +1298,7 @@ export class Collection implements OperationParent { options = options || {}; // Give function's options precedence over session's options. if (options.ignoreUndefined == null) { - options.ignoreUndefined = this.s.options.ignoreUndefined; + options.ignoreUndefined = this.bsonOptions.ignoreUndefined; } return new OrderedBulkOperation(this, options); @@ -1414,12 +1357,6 @@ export class Collection implements OperationParent { if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // Add ignoreUndefined - if (this.s.options.ignoreUndefined) { - options = Object.assign({}, options); - options.ignoreUndefined = this.s.options.ignoreUndefined; - } - return this.updateMany(selector, update, options, callback); } @@ -1439,12 +1376,6 @@ export class Collection implements OperationParent { if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // Add ignoreUndefined - if (this.s.options.ignoreUndefined) { - options = Object.assign({}, options); - options.ignoreUndefined = this.s.options.ignoreUndefined; - } - return this.deleteMany(selector, options, callback); } diff --git a/src/db.ts b/src/db.ts index d8c8dab79b7..fe8eda00cc5 100644 --- a/src/db.ts +++ b/src/db.ts @@ -2,7 +2,7 @@ import { deprecate } from 'util'; import { emitDeprecatedOptionWarning, Callback } from './utils'; import { loadAdmin } from './dynamic_loaders'; import { AggregationCursor, CommandCursor } from './cursor'; -import { ObjectId, Code, Document, BSONSerializeOptions } from './bson'; +import { ObjectId, Code, Document, BSONSerializeOptions, resolveBSONOptions } from './bson'; import { ReadPreference, ReadPreferenceLike } from './read_preference'; import { MongoError } from './error'; import { Collection, CollectionOptions } from './collection'; @@ -94,6 +94,7 @@ export interface DbPrivate { readPreference?: ReadPreference; pkFactory: PkFactory; readConcern?: ReadConcern; + bsonOptions: BSONSerializeOptions; writeConcern?: WriteConcern; namespace: MongoDBNamespace; } @@ -171,6 +172,8 @@ export class Db implements OperationParent { logger: new Logger('Db', options), // Unpack read preference readPreference: ReadPreference.fromOptions(options), + // Merge bson options TODO: include client bson options, after NODE-2850 + bsonOptions: resolveBSONOptions(options), // Set up the primary key factory or fallback to ObjectId pkFactory: options?.pkFactory ?? { createPk() { @@ -218,6 +221,10 @@ export class Db implements OperationParent { return this.s.readPreference; } + get bsonOptions(): BSONSerializeOptions { + return this.s.bsonOptions; + } + // get the write Concern get writeConcern(): WriteConcern | undefined { return this.s.writeConcern; @@ -340,11 +347,6 @@ export class Db implements OperationParent { // If we have not set a collection level readConcern set the db level one options.readConcern = ReadConcern.fromOptions(options) ?? this.readConcern; - // Do we have ignoreUndefined set - if (this.s.options?.ignoreUndefined) { - options.ignoreUndefined = this.s.options.ignoreUndefined; - } - // Merge in all needed options and ensure correct writeConcern merging from db level const finalOptions = mergeOptionsAndWriteConcern( options, diff --git a/src/mongo_client.ts b/src/mongo_client.ts index c5a275f8636..8b82fb890f5 100644 --- a/src/mongo_client.ts +++ b/src/mongo_client.ts @@ -10,7 +10,7 @@ import { connect, validOptions } from './operations/connect'; import { PromiseProvider } from './promise_provider'; import { Logger } from './logger'; import { ReadConcern, ReadConcernLevelLike, ReadConcernLike } from './read_concern'; -import type { BSONSerializeOptions, Document } from './bson'; +import { BSONSerializeOptions, Document, resolveBSONOptions } from './bson'; import type { AutoEncryptionOptions } from './deps'; import type { CompressorName } from './cmap/wire_protocol/compression'; import type { AuthMechanism } from './cmap/auth/defaultAuthProviders'; @@ -222,6 +222,7 @@ export interface MongoClientPrivate { readConcern?: ReadConcern; writeConcern?: WriteConcern; readPreference: ReadPreference; + bsonOptions: BSONSerializeOptions; namespace: MongoDBNamespace; logger: Logger; } @@ -284,6 +285,7 @@ export class MongoClient extends EventEmitter implements OperationParent { readConcern: ReadConcern.fromOptions(options), writeConcern: WriteConcern.fromOptions(options), readPreference: ReadPreference.fromOptions(options) || ReadPreference.primary, + bsonOptions: resolveBSONOptions(options), namespace: new MongoDBNamespace('admin'), logger: options?.logger ?? new Logger('MongoClient') }; @@ -301,6 +303,10 @@ export class MongoClient extends EventEmitter implements OperationParent { return this.s.readPreference; } + get bsonOptions(): BSONSerializeOptions { + return this.s.bsonOptions; + } + get logger(): Logger { return this.s.logger; } diff --git a/src/operations/bulk_write.ts b/src/operations/bulk_write.ts index 9656cefd860..6838f6fe5eb 100644 --- a/src/operations/bulk_write.ts +++ b/src/operations/bulk_write.ts @@ -1,5 +1,6 @@ import { applyRetryableWrites, applyWriteConcern, Callback } from '../utils'; import { OperationBase } from './operation'; +import { resolveBSONOptions } from '../bson'; import { WriteConcern } from '../write_concern'; import type { Collection } from '../collection'; import type { @@ -24,18 +25,15 @@ export class BulkWriteOperation extends OperationBase): void { const coll = this.collection; const operations = this.operations; - let options = this.options; - - // Add ignoreUndefined - if (coll.s.options.ignoreUndefined) { - options = Object.assign({}, options); - options.ignoreUndefined = coll.s.options.ignoreUndefined; - } + const options = { ...this.options, ...this.bsonOptions }; // Create the bulk operation const bulk: BulkOperationBase = diff --git a/src/operations/command.ts b/src/operations/command.ts index eb1a101e167..818610402ac 100644 --- a/src/operations/command.ts +++ b/src/operations/command.ts @@ -7,7 +7,7 @@ import { commandSupportsReadConcern } from '../sessions'; import { MongoError } from '../error'; import type { Logger } from '../logger'; import type { Server } from '../sdam/server'; -import type { Document } from '../bson'; +import { BSONSerializeOptions, Document, resolveBSONOptions } from '../bson'; import type { CollationOptions } from '../cmap/wire_protocol/write_command'; import type { ReadConcernLike } from './../read_concern'; @@ -42,6 +42,7 @@ export interface OperationParent { writeConcern?: WriteConcern; readPreference?: ReadPreference; logger?: Logger; + bsonOptions?: BSONSerializeOptions; } /** @internal */ @@ -90,6 +91,9 @@ export abstract class CommandOperation< if (parent && parent.logger) { this.logger = parent.logger; } + + // Assign BSON serialize options to OperationBase, preferring options over parent options. + this.bsonOptions = resolveBSONOptions(options, parent); } abstract execute(server: Server, callback: Callback): void; @@ -98,7 +102,7 @@ export abstract class CommandOperation< // TODO: consider making this a non-enumerable property this.server = server; - const options = this.options; + const options = { ...this.options, ...this.bsonOptions }; const serverWireVersion = maxWireVersion(server); const inTransaction = this.session && this.session.inTransaction(); diff --git a/src/operations/common_functions.ts b/src/operations/common_functions.ts index a1253538b59..be66758e061 100644 --- a/src/operations/common_functions.ts +++ b/src/operations/common_functions.ts @@ -250,7 +250,8 @@ export function updateDocuments( // Do we return the actual result document // Either use override on the function, or go back to default on either the collection // level or db - finalOptions.serializeFunctions = options.serializeFunctions || coll.s.serializeFunctions; + finalOptions.serializeFunctions = + options.serializeFunctions || coll.bsonOptions.serializeFunctions; // Execute the operation const op: Document = { q: selector, u: document }; diff --git a/src/operations/delete.ts b/src/operations/delete.ts index a36a03e8dbd..5ed6b750b11 100644 --- a/src/operations/delete.ts +++ b/src/operations/delete.ts @@ -65,7 +65,7 @@ export class DeleteOneOperation extends CommandOperation): void { const coll = this.collection; const filter = this.filter; - const options = this.options; + const options = { ...this.options, ...this.bsonOptions }; options.single = true; removeDocuments(server, coll, filter, options, (err, r) => { @@ -99,7 +99,7 @@ export class DeleteManyOperation extends CommandOperation): void { const coll = this.collection; const filter = this.filter; - const options = this.options; + const options = { ...this.options, ...this.bsonOptions }; // a user can pass `single: true` in to `deleteMany` to remove a single document, theoretically if (typeof options.single !== 'boolean') { diff --git a/src/operations/find.ts b/src/operations/find.ts index 93449831282..148ff478d20 100644 --- a/src/operations/find.ts +++ b/src/operations/find.ts @@ -113,15 +113,6 @@ export class FindOperation extends CommandOperation { find: this.ns.toString(), query: this.filter }; - - // TODO: figure out our story about inheriting BSON serialization options - this.bsonOptions = { - raw: options.raw ?? collection.s.raw ?? false, - promoteLongs: options.promoteLongs ?? collection.s.promoteLongs ?? true, - promoteValues: options.promoteValues ?? collection.s.promoteValues ?? true, - promoteBuffers: options.promoteBuffers ?? collection.s.promoteBuffers ?? false, - ignoreUndefined: options.ignoreUndefined ?? collection.s.ignoreUndefined ?? false - }; } execute(server: Server, callback: Callback): void { diff --git a/src/operations/find_and_modify.ts b/src/operations/find_and_modify.ts index 748fd1d8af0..aa5545638d0 100644 --- a/src/operations/find_and_modify.ts +++ b/src/operations/find_and_modify.ts @@ -71,7 +71,7 @@ export class FindAndModifyOperation extends CommandOperation { this.collection = collection; this.query = query; + + // Assign BSON serialize options to OperationBase, preferring options over collection options + this.bsonOptions = resolveBSONOptions(options, collection); } execute(server: Server, callback: Callback): void { const coll = this.collection; const query = this.query; - const options = this.options; + const options = { ...this.options, ...this.bsonOptions }; try { const cursor = coll.find(query, options).limit(-1).batchSize(1); diff --git a/src/operations/insert.ts b/src/operations/insert.ts index 772c7ac8c8f..0b4b431f765 100644 --- a/src/operations/insert.ts +++ b/src/operations/insert.ts @@ -65,7 +65,7 @@ export class InsertOneOperation extends CommandOperation): void { const coll = this.collection; const doc = this.doc; - const options = this.options; + const options = { ...this.options, ...this.bsonOptions }; if (Array.isArray(doc)) { return callback( @@ -105,7 +105,6 @@ function insertDocuments( // If keep going set unordered if (finalOptions.keepGoing === true) finalOptions.ordered = false; - finalOptions.serializeFunctions = options.serializeFunctions || coll.s.serializeFunctions; docs = prepareDocs(coll, docs, options); diff --git a/src/operations/insert_many.ts b/src/operations/insert_many.ts index afd87c95780..e5a15fc0c6e 100644 --- a/src/operations/insert_many.ts +++ b/src/operations/insert_many.ts @@ -4,7 +4,7 @@ import { MongoError } from '../error'; import { prepareDocs } from './common_functions'; import type { Callback } from '../utils'; import type { Collection } from '../collection'; -import type { ObjectId, Document } from '../bson'; +import { ObjectId, Document, resolveBSONOptions } from '../bson'; import type { BulkWriteResult, BulkWriteOptions } from '../bulk/common'; import type { Server } from '../sdam/server'; @@ -30,12 +30,15 @@ export class InsertManyOperation extends OperationBase): void { const coll = this.collection; let docs = this.docs; - const options = this.options; + const options = { ...this.options, ...this.bsonOptions }; if (!Array.isArray(docs)) { return callback( @@ -43,9 +46,6 @@ export class InsertManyOperation extends OperationBase { + const db = client.db(configuration.db, { ignoreUndefined: true }); + const collection = db.collection('shouldCorrectlyIgnoreUndefinedValue3'); + + // Ignore the undefined field + collection.insert({ a: 1, b: undefined }, configuration.writeConcernMax(), err => { + expect(err).to.not.exist; + + // Locate the doument + collection.findOne((err, item) => { + expect(err).to.not.exist; + expect(item).to.have.property('a', 1); + expect(item).to.not.have.property('b'); + done(); + }); + }); + }); + }); + + it( + 'Should correctly inherit ignore undefined field from collection during insert', + withClient(function (client, done) { + const db = client.db('shouldCorrectlyIgnoreUndefinedValue4', { ignoreUndefined: false }); + const collection = db.collection('shouldCorrectlyIgnoreUndefinedValue4', { + ignoreUndefined: true + }); + + // Ignore the undefined field + collection.insert({ a: 1, b: undefined }, err => { + expect(err).to.not.exist; + + // Locate the doument + collection.findOne((err, item) => { + expect(err).to.not.exist; + expect(item).to.have.property('a', 1); + expect(item).to.not.have.property('b'); + done(); + }); + }); + }) + ); + + it( + 'Should correctly inherit ignore undefined field from operation during insert', + withClient(function (client, done) { + const db = client.db('shouldCorrectlyIgnoreUndefinedValue5'); + const collection = db.collection('shouldCorrectlyIgnoreUndefinedValue5', { + ignoreUndefined: false + }); + + // Ignore the undefined field + collection.insert({ a: 1, b: undefined }, { ignoreUndefined: true }, err => { + expect(err).to.not.exist; + + // Locate the doument + collection.findOne({}, (err, item) => { + expect(err).to.not.exist; + expect(item).to.have.property('a', 1); + expect(item).to.not.have.property('b'); + done(); + }); + }); + }) + ); + + it( + 'Should correctly inherit ignore undefined field from operation during findOneAndReplace', + withClient(function (client, done) { + const db = client.db('shouldCorrectlyIgnoreUndefinedValue6'); + const collection = db.collection('shouldCorrectlyIgnoreUndefinedValue6', { + ignoreUndefined: false + }); + + collection.insert({ a: 1, b: 2 }, err => { + expect(err).to.not.exist; + + // Replace the doument, ignoring undefined fields + collection.findOneAndReplace({}, { a: 1, b: undefined }, { ignoreUndefined: true }, err => { + expect(err).to.not.exist; + + // Locate the doument + collection.findOne((err, item) => { + expect(err).to.not.exist; + expect(item).to.have.property('a', 1); + expect(item).to.not.have.property('b'); + done(); + }); + }); + }); + }) + ); + + it( + 'Should correctly ignore undefined field during bulk write', + withClient(function (client, done) { + const db = client.db('shouldCorrectlyIgnoreUndefinedValue7'); + const collection = db.collection('shouldCorrectlyIgnoreUndefinedValue7'); + + // Ignore the undefined field + collection.bulkWrite( + [{ insertOne: { a: 1, b: undefined } }], + { ignoreUndefined: true }, + err => { + expect(err).to.not.exist; + + // Locate the doument + collection.findOne((err, item) => { + expect(err).to.not.exist; + expect(item).to.have.property('a', 1); + expect(item).to.not.have.property('b'); + done(); + }); + } + ); + }) + ); }); diff --git a/test/functional/insert.test.js b/test/functional/insert.test.js index 78387639a87..1f51543c8cd 100644 --- a/test/functional/insert.test.js +++ b/test/functional/insert.test.js @@ -1,5 +1,5 @@ 'use strict'; -const { assert: test } = require('./shared'); +const { assert: test, withClient } = require('./shared'); const { setupDatabase } = require('./shared'); const Script = require('vm'); const { expect } = require('chai'); @@ -1902,6 +1902,65 @@ describe('Insert', function () { } }); + it('shouldCorrectlyInheritPromoteLongFalseNativeBSONWithGetMore', { + metadata: { + requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } + }, + + test: withClient((client, done) => { + const db = client.db('shouldCorrectlyInheritPromoteLongFalseNativeBSONWithGetMore', { + promoteLongs: true + }); + const collection = db.collection('test', { promoteLongs: false }); + collection.insertMany( + [ + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) }, + { a: Long.fromNumber(10) } + ], + (err, doc) => { + expect(err).to.not.exist; + test.ok(doc); + + collection + .find({}) + .batchSize(2) + .toArray((err, docs) => { + expect(err).to.not.exist; + + docs.forEach((d, i) => { + expect(d.a, `Failed on the document at index ${i}`).to.not.be.a('number'); + expect(d.a, `Failed on the document at index ${i}`).to.have.property('_bsontype'); + expect(d.a._bsontype, `Failed on the document at index ${i}`).to.be.equal('Long'); + }); + done(); + }); + } + ); + }) + }); + it('shouldCorrectlyHonorPromoteLongTrueNativeBSON', { // 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 diff --git a/test/functional/mongo_client.test.js b/test/functional/mongo_client.test.js index 90dbf01d11f..860de1afdad 100644 --- a/test/functional/mongo_client.test.js +++ b/test/functional/mongo_client.test.js @@ -57,8 +57,8 @@ describe('MongoClient', function () { test.equal(true, db.s.options.forceServerObjectId); test.equal(1, db.s.pkFactory.createPk()); - test.equal(true, db.s.options.serializeFunctions); - test.equal(true, db.s.options.raw); + test.equal(true, db.bsonOptions.serializeFunctions); + test.equal(true, db.bsonOptions.raw); test.equal(10, db.s.options.numberOfRetries); test.equal(0, db.s.options.bufferMaxEntries);