Skip to content

Commit 59a0db7

Browse files
committed
fix utils bug and test
1 parent c582310 commit 59a0db7

File tree

2 files changed

+48
-51
lines changed

2 files changed

+48
-51
lines changed

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export function mergeOptionsAndWriteConcern(
276276
): AnyOptions {
277277
// Mix in any allowed options
278278
for (let i = 0; i < keys.length; i++) {
279-
if (!targetOptions[keys[i]] && sourceOptions[keys[i]] !== undefined) {
279+
if (targetOptions[keys[i]] === undefined && sourceOptions[keys[i]] !== undefined) {
280280
targetOptions[keys[i]] = sourceOptions[keys[i]];
281281
}
282282
}

test/functional/insert.test.js

Lines changed: 47 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,61 +1909,58 @@ describe('Insert', function () {
19091909
requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] }
19101910
},
19111911

1912-
test: function () {
1913-
var configuration = this.configuration;
1914-
1915-
var client = configuration.newClient(configuration.writeConcernMax(), {
1916-
poolSize: 1,
1912+
test: withClient((client, done) => {
1913+
const db = client.db('shouldCorrectlyInheritPromoteLongFalseNativeBSONWithGetMore', {
19171914
promoteLongs: true
19181915
});
1916+
const collection = db.collection('test', { promoteLongs: false });
1917+
collection.insertMany(
1918+
[
1919+
{ a: Long.fromNumber(10) },
1920+
{ a: Long.fromNumber(10) },
1921+
{ a: Long.fromNumber(10) },
1922+
{ a: Long.fromNumber(10) },
1923+
{ a: Long.fromNumber(10) },
1924+
{ a: Long.fromNumber(10) },
1925+
{ a: Long.fromNumber(10) },
1926+
{ a: Long.fromNumber(10) },
1927+
{ a: Long.fromNumber(10) },
1928+
{ a: Long.fromNumber(10) },
1929+
{ a: Long.fromNumber(10) },
1930+
{ a: Long.fromNumber(10) },
1931+
{ a: Long.fromNumber(10) },
1932+
{ a: Long.fromNumber(10) },
1933+
{ a: Long.fromNumber(10) },
1934+
{ a: Long.fromNumber(10) },
1935+
{ a: Long.fromNumber(10) },
1936+
{ a: Long.fromNumber(10) },
1937+
{ a: Long.fromNumber(10) },
1938+
{ a: Long.fromNumber(10) },
1939+
{ a: Long.fromNumber(10) },
1940+
{ a: Long.fromNumber(10) },
1941+
{ a: Long.fromNumber(10) },
1942+
{ a: Long.fromNumber(10) }
1943+
],
1944+
(err, doc) => {
1945+
expect(err).to.not.exist;
1946+
test.ok(doc);
19191947

1920-
return withClient(client, (client, done) => {
1921-
var db = client.db(configuration.db, { promoteLongs: false });
1922-
db.collection('shouldCorrectlyInheritPromoteLongFalseNativeBSONWithGetMore').insertMany(
1923-
[
1924-
{ a: Long.fromNumber(10) },
1925-
{ a: Long.fromNumber(10) },
1926-
{ a: Long.fromNumber(10) },
1927-
{ a: Long.fromNumber(10) },
1928-
{ a: Long.fromNumber(10) },
1929-
{ a: Long.fromNumber(10) },
1930-
{ a: Long.fromNumber(10) },
1931-
{ a: Long.fromNumber(10) },
1932-
{ a: Long.fromNumber(10) },
1933-
{ a: Long.fromNumber(10) },
1934-
{ a: Long.fromNumber(10) },
1935-
{ a: Long.fromNumber(10) },
1936-
{ a: Long.fromNumber(10) },
1937-
{ a: Long.fromNumber(10) },
1938-
{ a: Long.fromNumber(10) },
1939-
{ a: Long.fromNumber(10) },
1940-
{ a: Long.fromNumber(10) },
1941-
{ a: Long.fromNumber(10) },
1942-
{ a: Long.fromNumber(10) },
1943-
{ a: Long.fromNumber(10) },
1944-
{ a: Long.fromNumber(10) },
1945-
{ a: Long.fromNumber(10) },
1946-
{ a: Long.fromNumber(10) },
1947-
{ a: Long.fromNumber(10) }
1948-
],
1949-
(err, doc) => {
1950-
expect(err).to.not.exist;
1951-
test.ok(doc);
1952-
1953-
db.collection('shouldCorrectlyInheritPromoteLongFalseNativeBSONWithGetMore')
1954-
.find({})
1955-
.batchSize(2)
1956-
.toArray((err, docs) => {
1957-
expect(err).to.not.exist;
1958-
var doc = docs.pop();
1948+
collection
1949+
.find({})
1950+
.batchSize(2)
1951+
.toArray((err, docs) => {
1952+
expect(err).to.not.exist;
19591953

1960-
test.ok(doc.a._bsontype === 'Long');
1961-
done();
1954+
docs.forEach((d, i) => {
1955+
expect(d.a, `Failed on the document at index ${i}`).to.not.be.a('number');
1956+
expect(d.a, `Failed on the document at index ${i}`).to.have.property('_bsontype');
1957+
expect(d.a._bsontype, `Failed on the document at index ${i}`).to.be.equal('Long');
19621958
});
1963-
}
1964-
);
1965-
});
1966-
}
1959+
done();
1960+
});
1961+
}
1962+
);
1963+
})
19671964
});
19681965

19691966
it('shouldCorrectlyHonorPromoteLongTrueNativeBSON', {

0 commit comments

Comments
 (0)