Skip to content

Commit 84af035

Browse files
authored
Merge branch 'main' into gagik/report-individual-tests
2 parents 3c2be35 + 15faeba commit 84af035

File tree

5 files changed

+29
-21
lines changed

5 files changed

+29
-21
lines changed

THIRD_PARTY_NOTICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The following third-party software is used by and included in **mongosh**.
2-
This document was automatically generated on Thu Oct 17 2024.
2+
This document was automatically generated on Fri Oct 18 2024.
33

44
## List of dependencies
55

packages/shell-api/src/collection.spec.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,26 +1165,27 @@ describe('Collection', function () {
11651165
context(
11661166
'when serviceProvider.dropIndexes rejects IndexNotFound',
11671167
function () {
1168+
let expectedError: Error;
11681169
beforeEach(function () {
1169-
const error = new Error('index not found with name [index_1]');
1170-
Object.assign(error, {
1170+
expectedError = new Error('index not found with name [index_1]');
1171+
Object.assign(expectedError, {
11711172
ok: 0,
11721173
errmsg: 'index not found with name [index_1]',
11731174
code: 27,
11741175
codeName: 'IndexNotFound',
1175-
name: 'MongoError',
1176+
name: 'MongoServerError',
11761177
});
11771178

1178-
serviceProvider.runCommandWithCheck.rejects(error);
1179+
serviceProvider.runCommandWithCheck.rejects(expectedError);
11791180
});
11801181

11811182
it('returns the error as object', async function () {
1182-
expect(await collection.dropIndexes('index_1')).to.deep.equal({
1183-
ok: 0,
1184-
errmsg: 'index not found with name [index_1]',
1185-
code: 27,
1186-
codeName: 'IndexNotFound',
1187-
});
1183+
let caughtError: Error | undefined;
1184+
await collection
1185+
.dropIndexes('index_1')
1186+
.catch((err) => (caughtError = err));
1187+
1188+
expect(caughtError).to.deep.equal(expectedError);
11881189
});
11891190
}
11901191
);

packages/shell-api/src/collection.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,15 +1335,6 @@ export default class Collection extends ShellApiWithMongoClass {
13351335
return all.sort((a, b) => b.nIndexesWas - a.nIndexesWas)[0];
13361336
}
13371337

1338-
if (error?.codeName === 'IndexNotFound') {
1339-
return {
1340-
ok: error.ok,
1341-
errmsg: error.errmsg,
1342-
code: error.code,
1343-
codeName: error.codeName,
1344-
};
1345-
}
1346-
13471338
throw error;
13481339
}
13491340
}

packages/shell-api/src/database.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,16 @@ describe('Database', function () {
400400
);
401401
});
402402

403+
it('supports a single aggregation stage', async function () {
404+
await database.aggregate({ $piplelineStage: {} }, { options: true });
405+
406+
expect(serviceProvider.aggregateDb).to.have.been.calledWith(
407+
database._name,
408+
[{ $piplelineStage: {} }],
409+
{ options: true }
410+
);
411+
});
412+
403413
it('calls serviceProvider.aggregateDb with explicit batchSize', async function () {
404414
await database.aggregate([{ $piplelineStage: {} }], {
405415
options: true,

packages/shell-api/src/database.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,15 +423,20 @@ export default class Database extends ShellApiWithMongoClass {
423423
@returnType('AggregationCursor')
424424
@apiVersions([1])
425425
async aggregate(
426-
pipeline: Document[],
426+
pipelineOrSingleStage: Document | Document[],
427427
options?: Document
428428
): Promise<AggregationCursor> {
429429
if ('background' in (options ?? {})) {
430430
await this._instanceState.printWarning(
431431
aggregateBackgroundOptionNotSupportedHelp
432432
);
433433
}
434+
const pipeline: Document[] = Array.isArray(pipelineOrSingleStage)
435+
? pipelineOrSingleStage
436+
: [pipelineOrSingleStage];
437+
434438
assertArgsDefinedType([pipeline], [true], 'Database.aggregate');
439+
435440
this._emitDatabaseApiCall('aggregate', { options, pipeline });
436441

437442
const { aggOptions, dbOptions, explain } = adaptAggregateOptions(options);
@@ -1429,6 +1434,7 @@ export default class Database extends ShellApiWithMongoClass {
14291434
CommonErrors.CommandFailed
14301435
);
14311436
}
1437+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
14321438
for (const cmdDescription of Object.values(result.commands) as Document[]) {
14331439
if ('slaveOk' in cmdDescription) {
14341440
cmdDescription.secondaryOk = cmdDescription.slaveOk;

0 commit comments

Comments
 (0)