Skip to content

Commit 12b5768

Browse files
don't do chagnes to submodule
1 parent 091ebaa commit 12b5768

File tree

6 files changed

+27
-49
lines changed

6 files changed

+27
-49
lines changed

src/mongo_client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
794794
this,
795795
new RunAdminCommandOperation(
796796
{ endSessions },
797-
{ readPreference: ReadPreference.primaryPreferred, writeConcern: { w: 0 } }
797+
{ readPreference: ReadPreference.primaryPreferred, noResponse: true }
798798
)
799799
);
800800
} catch (error) {

src/operations/command.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ export abstract class ModernizedCommandOperation<T> extends ModernizedOperation<
262262
return decorateWithExplain(command, this.explain);
263263
}
264264

265-
console.log(command);
266-
267265
return command;
268266
}
269267
}

src/operations/distinct.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ export class DistinctOperation extends ModernizedCommandOperation<any[] | Docume
6666
if (this.options.comment !== undefined) {
6767
command.comment = this.options.comment;
6868
}
69+
70+
if (this.options.hint != null) {
71+
command.hint = this.options.hint;
72+
}
73+
6974
return command;
7075
}
7176

src/operations/run_command.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { type Abortable } from '..';
12
import type { BSONSerializeOptions, Document } from '../bson';
23
import { type Connection } from '../cmap/connection';
34
import {
@@ -28,7 +29,8 @@ export type RunCommandOptions = {
2829
timeoutMS?: number;
2930
/** @internal */
3031
omitMaxTimeMS?: boolean;
31-
} & BSONSerializeOptions;
32+
} & BSONSerializeOptions &
33+
Abortable;
3234

3335
/** @internal */
3436
export class RunCommandOperation<T = Document> extends ModernizedCommandOperation<T> {
@@ -56,7 +58,7 @@ export class RunCommandOperation<T = Document> extends ModernizedCommandOperatio
5658
}
5759

5860
override buildOptions(timeoutContext: TimeoutContext): ServerCommandOptions {
59-
return { session: this.session, timeoutContext };
61+
return { session: this.session, timeoutContext, signal: this.options.signal };
6062
}
6163
}
6264

@@ -101,13 +103,15 @@ export class RunAdminCommandOperation<T = Document> extends ModernizedCommandOpe
101103
override options: RunCommandOptions & {
102104
writeConcern?: WriteConcern;
103105
bypassPinningCheck?: boolean;
106+
noResponse?: boolean;
104107
};
105108

106109
constructor(
107110
command: Document,
108111
options: RunCommandOptions & {
109112
writeConcern?: WriteConcern;
110113
bypassPinningCheck?: boolean;
114+
noResponse?: boolean;
111115
}
112116
) {
113117
super(undefined, options);
@@ -125,6 +129,6 @@ export class RunAdminCommandOperation<T = Document> extends ModernizedCommandOpe
125129
}
126130

127131
override buildOptions(timeoutContext: TimeoutContext): ServerCommandOptions {
128-
return { session: this.session, timeoutContext };
132+
return { session: this.session, timeoutContext, noResponse: this.options.noResponse };
129133
}
130134
}

test/integration/index_management.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
type MongoClient,
99
MongoServerError
1010
} from '../mongodb';
11+
import { type FailPoint } from '../tools/utils';
1112
import { assert as test, filterForCommands, setupDatabase } from './shared';
1213

1314
describe('Indexes', function () {
@@ -36,6 +37,19 @@ describe('Indexes', function () {
3637
expect(response).to.exist;
3738
});
3839

40+
it('createIndex() throws an error error when createIndex fails', async function () {
41+
await client.db('admin').command(<FailPoint>{
42+
configureFailPoint: 'failCommand',
43+
mode: { times: 1 },
44+
data: {
45+
failCommands: ['createIndexes'],
46+
errorCode: 10
47+
}
48+
});
49+
const error = await db.createIndex('promiseCollectionCollections1', { a: 1 }).catch(e => e);
50+
expect(error).to.be.instanceOf(MongoServerError);
51+
});
52+
3953
it('shouldCorrectlyExtractIndexInformation', async function () {
4054
const collection = await db.createCollection('test_index_information');
4155
await collection.insertMany([{ a: 1 }], this.configuration.writeConcernMax());

test/unit/collection.test.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,6 @@ describe('Collection', function () {
1414
await cleanup();
1515
});
1616

17-
context('#createIndex', () => {
18-
let client;
19-
20-
before(function () {
21-
client = new MongoClient(`mongodb://${server.uri()}`);
22-
});
23-
24-
after(async function () {
25-
await client.close();
26-
});
27-
28-
it('should error when createIndex fails', async function () {
29-
const ERROR_RESPONSE = {
30-
ok: 0,
31-
errmsg:
32-
'WiredTigerIndex::insert: key too large to index, failing 1470 { : "56f37cb8e4b089e98d52ab0e", : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..." }',
33-
code: 17280
34-
};
35-
36-
server.setMessageHandler(request => {
37-
const doc = request.document;
38-
39-
if (isHello(doc)) {
40-
return request.reply(Object.assign({}, HELLO));
41-
}
42-
43-
if (doc.createIndexes) {
44-
return request.reply(ERROR_RESPONSE);
45-
}
46-
47-
if (doc.insert === 'system.indexes') {
48-
return request.reply(ERROR_RESPONSE);
49-
}
50-
});
51-
52-
const coll = client.db('foo').collection('bar');
53-
const e = await coll.createIndex({ a: 1 }).catch(e => e);
54-
expect(e).to.have.property('ok', ERROR_RESPONSE.ok);
55-
expect(e).to.have.property('errmsg', ERROR_RESPONSE.errmsg);
56-
expect(e).to.have.property('code', ERROR_RESPONSE.code);
57-
});
58-
});
59-
6017
context('#aggregate', () => {
6118
// general test for aggregate function
6219
function testAggregate(config, done) {

0 commit comments

Comments
 (0)