Skip to content

Commit a351b2c

Browse files
committed
respond to comments
1 parent 8f5fb8b commit a351b2c

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/operations/command.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@ export abstract class CommandOperation<
7373
: new MongoDBNamespace('admin', '$cmd');
7474
}
7575

76-
const readPref = ReadPreference.fromOptions(options) ?? ReadPreference.primary;
7776
this.readPreference = this.hasAspect(Aspect.WRITE_OPERATION)
7877
? ReadPreference.primary
79-
: readPref;
78+
: ReadPreference.fromOptions(options) ?? ReadPreference.primary;
8079
this.readConcern = ReadConcern.fromOptions(options);
8180
this.writeConcern = WriteConcern.fromOptions(options);
8281
this.bsonOptions = resolveBSONOptions(options);

src/utils.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { ReadConcern } from './read_concern';
1414
import type { Connection } from './cmap/connection';
1515
import { readFileSync } from 'fs';
1616
import { resolve } from 'path';
17-
import { Document, resolveBSONOptions } from './bson';
17+
import { BSONSerializeOptions, Document, resolveBSONOptions } from './bson';
1818
import type { IndexSpecification, IndexDirection } from './operations/indexes';
1919
import type { MongoClient } from './mongo_client';
2020
import type { Cursor } from './cursor/cursor';
@@ -1091,10 +1091,10 @@ export function resolveOptions<T extends CommandOperationOptions>(
10911091
parent: OperationParent | undefined,
10921092
options?: T
10931093
): T {
1094-
const result: T = Object.assign({}, options);
1095-
const session = options?.session;
1094+
const result: T = Object.assign({}, options, resolveBSONOptions(options, parent));
10961095

10971096
// Users cannot pass a readConcern/writeConcern to operations in a transaction
1097+
const session = options?.session;
10981098
if (!session?.inTransaction()) {
10991099
const readConcern = ReadConcern.fromOptions(options) ?? parent?.readConcern;
11001100
if (readConcern) {
@@ -1112,7 +1112,5 @@ export function resolveOptions<T extends CommandOperationOptions>(
11121112
result.readPreference = readPreference;
11131113
}
11141114

1115-
const bsonOptions = resolveBSONOptions(result, parent);
1116-
1117-
return { ...result, ...bsonOptions };
1115+
return result;
11181116
}

0 commit comments

Comments
 (0)