Skip to content

Commit 9c5c928

Browse files
mbroadstdaprahamian
authored andcommitted
refactor(command): report an error if collation not supported
1 parent a582042 commit 9c5c928

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/operations/command_v2.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const ReadConcern = require('../read_concern');
77
const WriteConcern = require('../write_concern');
88
const maxWireVersion = require('../core/utils').maxWireVersion;
99
const commandSupportsReadConcern = require('../core/sessions').commandSupportsReadConcern;
10+
const MongoError = require('../error').MongoError;
1011

1112
const SUPPORTS_WRITE_CONCERN_AND_COLLATION = 5;
1213

@@ -44,6 +45,17 @@ class CommandOperationV2 extends OperationBase {
4445
Object.assign(cmd, { readConcern: this.readConcern });
4546
}
4647

48+
if (options.collation && serverWireVersion < SUPPORTS_WRITE_CONCERN_AND_COLLATION) {
49+
callback(
50+
new MongoError(
51+
`Server ${
52+
server.name
53+
}, which reports wire version ${serverWireVersion}, does not support collation`
54+
)
55+
);
56+
return;
57+
}
58+
4759
if (serverWireVersion >= SUPPORTS_WRITE_CONCERN_AND_COLLATION) {
4860
if (this.writeConcern && this.hasAspect(Aspect.WRITE_OPERATION)) {
4961
Object.assign(cmd, { writeConcern: this.writeConcern });

0 commit comments

Comments
 (0)