Skip to content

Commit 491bb8e

Browse files
authored
chore: bump driver and bson to latest MONGOSH-764 (#880)
- Bump driver to 4.0.0-beta.4 - Adjust options of the findAndModify/findOneAnd[...] methods to account for the changed TS definitions and the added `returnDocument` options, which supersedes all three other alternatives currently supported by the shell. - Bump bson to 4.4.0 - Adjust output for `Decimal128` and `Long` formatting. - Also addresses MONGOSH-709.
1 parent 3ab3266 commit 491bb8e

24 files changed

+196
-102
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
"karma-typescript": "^4.1.1",
122122
"lerna": "^3.10.7",
123123
"mocha": "^7.1.2",
124-
"mongodb": "4.0.0-beta.3",
124+
"mongodb": "4.0.0-beta.4",
125125
"mongodb-download-url": "^1.0.1",
126126
"mongodb-js-precommit": "^2.0.0",
127127
"nock": "^13.0.11",

packages/autocomplete/index.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,19 @@ describe('completer.completer', () => {
218218

219219
context('when context is collections', () => {
220220
it('matches a collection command', async() => {
221-
const i = 'db.shipwrecks.findAnd';
222-
expect(await completer(standalone440, i)).to.deep.equal([['db.shipwrecks.findAndModify'], i]);
221+
const i = 'db.shipwrecks.findOneAndUp';
222+
expect(await completer(standalone440, i)).to.deep.equal([['db.shipwrecks.findOneAndUpdate'], i]);
223223
});
224224

225225
it('matches a collection command if part of an expression', async() => {
226-
const i = 'var result = db.shipwrecks.findAnd';
227-
expect(await completer(standalone440, i)).to.deep.equal([['var result = db.shipwrecks.findAndModify'], i]);
226+
const i = 'var result = db.shipwrecks.findOneAndUp';
227+
expect(await completer(standalone440, i)).to.deep.equal([['var result = db.shipwrecks.findOneAndUpdate'], i]);
228228
});
229229

230230
it('returns all suggestions', async() => {
231231
const i = 'db.shipwrecks.';
232232
const collComplete = Object.keys(shellSignatures.Collection.attributes as any);
233-
const adjusted = collComplete.filter(c => !['count', 'update', 'remove', 'insert', 'save'].includes(c)).map(c => `${i}${c}`);
233+
const adjusted = collComplete.filter(c => !['count', 'update', 'remove', 'insert', 'save', 'findAndModify'].includes(c)).map(c => `${i}${c}`);
234234

235235
expect(await completer(sharded440, i)).to.deep.equal([adjusted, i]);
236236
});
@@ -239,7 +239,7 @@ describe('completer.completer', () => {
239239
const i = 'db.shipwrecks.find';
240240
expect(await completer(standalone440, i)).to.deep.equal([
241241
[
242-
'db.shipwrecks.find', 'db.shipwrecks.findAndModify',
242+
'db.shipwrecks.find',
243243
'db.shipwrecks.findOne', 'db.shipwrecks.findOneAndDelete',
244244
'db.shipwrecks.findOneAndReplace', 'db.shipwrecks.findOneAndUpdate'
245245
], i]);

packages/cli-repl/test/e2e-bson.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ describe('BSON e2e', function() {
4242
MinKey: 'MinKey()',
4343
MaxKey: 'MaxKey()',
4444
NumberInt: 'Int32(32)',
45-
NumberLong: 'Long.fromString("64")',
45+
NumberLong: 'Long("64")',
4646
Timestamp: 'Timestamp(1, 100)',
4747
Symbol: 'abc',
4848
Code: 'Code("abc")',
49-
NumberDecimal: 'Decimal128.fromString("1")',
49+
NumberDecimal: 'Decimal128("1")',
5050
BinData: 'Binary(Buffer.from("31323334", "hex"), 128)',
5151
ISODate: 'ISODate("2021-05-04T15:49:33.000Z")',
5252
RegExp: '/match/'
@@ -61,7 +61,7 @@ describe('BSON e2e', function() {
6161
Timestamp: new bson.Timestamp(1, 100),
6262
Symbol: new bson.BSONSymbol('abc'),
6363
Code: new bson.Code('abc'),
64-
NumberDecimal: bson.Decimal128.fromString('1'),
64+
NumberDecimal: new bson.Decimal128('1'),
6565
BinData: new bson.Binary(buffer, 128),
6666
ISODate: new Date('2021-05-04T15:49:33.000Z'),
6767
RegExp: /match/
@@ -177,12 +177,12 @@ describe('BSON e2e', function() {
177177
shell.assertNoErrors();
178178
});
179179
it('Decimal128 prints when returned from the server', async() => {
180-
const value = bson.Decimal128.fromString('1');
180+
const value = new bson.Decimal128('1');
181181
await shell.writeInputLine(`use ${dbName}`);
182182
await db.collection('test').insertOne({ value: value });
183183
await shell.writeInputLine('db.test.findOne().value');
184184
await eventually(() => {
185-
shell.assertContainsOutput('Decimal128.fromString("1")');
185+
shell.assertContainsOutput('Decimal128("1")');
186186
});
187187
shell.assertNoErrors();
188188
});
@@ -261,15 +261,15 @@ describe('BSON e2e', function() {
261261
const value = 'NumberLong("64")';
262262
await shell.writeInputLine(value);
263263
await eventually(() => {
264-
shell.assertContainsOutput('Long.fromString("64")');
264+
shell.assertContainsOutput('Long("64")');
265265
});
266266
shell.assertNoErrors();
267267
});
268268
it('NumberLong prints when created by user (> MAX_SAFE_INTEGER)', async() => {
269269
const value = 'NumberLong("345678654321234561")';
270270
await shell.writeInputLine(value);
271271
await eventually(() => {
272-
shell.assertContainsOutput('Long.fromString("345678654321234561")');
272+
shell.assertContainsOutput('Long("345678654321234561")');
273273
});
274274
shell.assertNoErrors();
275275
});
@@ -309,7 +309,7 @@ describe('BSON e2e', function() {
309309
const value = 'NumberDecimal("100")';
310310
await shell.writeInputLine(value);
311311
await eventually(() => {
312-
shell.assertContainsOutput('Decimal128.fromString("100")');
312+
shell.assertContainsOutput('Decimal128("100")');
313313
});
314314
shell.assertNoErrors();
315315
});
@@ -427,7 +427,7 @@ describe('BSON e2e', function() {
427427
shell.assertNoErrors();
428428
});
429429
it('Decimal128 has help when returned from the server', async() => {
430-
const value = bson.Decimal128.fromString('1');
430+
const value = new bson.Decimal128('1');
431431
await shell.writeInputLine(`use ${dbName}`);
432432
await db.collection('test').insertOne({ value: value });
433433
await shell.writeInputLine('db.test.findOne().value.help()');

packages/java-shell/src/main/kotlin/com/mongodb/mongosh/service/optionConverters.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ internal val findOneAndReplaceOptionsConverters: Map<String, (FindOneAndReplaceO
316316
typed("upsert", Boolean::class.java) { opt, value ->
317317
opt.upsert(value)
318318
},
319-
typed("returnOriginal", Boolean::class.java) { opt, value ->
320-
opt.returnDocument(if (value) ReturnDocument.BEFORE else ReturnDocument.AFTER)
319+
typed("returnDocument", String::class.java) { opt, value ->
320+
opt.returnDocument(if (value == "before") ReturnDocument.BEFORE else ReturnDocument.AFTER)
321321
},
322322
typed("collation", Map::class.java) { opt, value ->
323323
val collation = convert(Collation.builder(), collationConverters, collationDefaultConverter, value)
@@ -371,8 +371,8 @@ internal val findOneAndUpdateConverters: Map<String, (FindOneAndUpdateOptions, A
371371
typed("upsert", Boolean::class.java) { opt, value ->
372372
opt.upsert(value)
373373
},
374-
typed("returnOriginal", Boolean::class.java) { opt, value ->
375-
opt.returnDocument(if (value) ReturnDocument.BEFORE else ReturnDocument.AFTER)
374+
typed("returnDocument", String::class.java) { opt, value ->
375+
opt.returnDocument(if (value == "before") ReturnDocument.BEFORE else ReturnDocument.AFTER)
376376
},
377377
typed("arrayFilters", List::class.java) { opt, value ->
378378
if (value.any { it !is Document }) {

packages/node-runtime-worker-thread/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/node-runtime-worker-thread/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@mongosh/service-provider-core": "0.0.0-dev.0",
4343
"@mongosh/service-provider-server": "0.0.0-dev.0",
4444
"@mongosh/types": "0.0.0-dev.0",
45-
"bson": "^4.3.0",
45+
"bson": "^4.4.0",
4646
"interruptor": "^1.0.1",
4747
"postmsg-rpc": "^2.4.0"
4848
}

packages/service-provider-core/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/service-provider-core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"dependencies": {
3030
"@mongosh/errors": "0.0.0-dev.0",
3131
"@mongosh/i18n": "0.0.0-dev.0",
32-
"bson": "^4.3.0",
33-
"mongodb": "4.0.0-beta.3",
32+
"bson": "^4.4.0",
33+
"mongodb": "4.0.0-beta.4",
3434
"mongodb-build-info": "^1.1.1",
3535
"whatwg-url": "^8.4.0"
3636
},

packages/service-provider-core/src/all-transport-types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ export type {
3333
EstimatedDocumentCountOptions,
3434
ExplainOptions,
3535
ExplainVerbosityLike,
36-
FindAndModifyOptions,
36+
FindOneAndDeleteOptions,
37+
FindOneAndUpdateOptions,
38+
FindOneAndReplaceOptions,
3739
FindOperators,
3840
FindOptions,
3941
HedgeOptions,

0 commit comments

Comments
 (0)