1
1
import type { BSONSerializeOptions , Document } from '../bson' ;
2
- import { MongoCompatibilityError , MongoInvalidArgumentError } from '../error' ;
2
+ import { MongoInvalidArgumentError } from '../error' ;
3
3
import { Explain , ExplainOptions } from '../explain' ;
4
4
import type { Logger } from '../logger' ;
5
5
import { ReadConcern } from '../read_concern' ;
@@ -18,8 +18,6 @@ import { WriteConcern, WriteConcernOptions } from '../write_concern';
18
18
import type { ReadConcernLike } from './../read_concern' ;
19
19
import { AbstractOperation , Aspect , OperationOptions } from './operation' ;
20
20
21
- const SUPPORTS_WRITE_CONCERN_AND_COLLATION = 5 ;
22
-
23
21
/** @public */
24
22
export interface CollationOptions {
25
23
locale : string ;
@@ -152,40 +150,24 @@ export abstract class CommandOperation<T> extends AbstractOperation<T> {
152
150
options . omitReadPreference = true ;
153
151
}
154
152
155
- if ( options . collation && serverWireVersion < SUPPORTS_WRITE_CONCERN_AND_COLLATION ) {
156
- callback (
157
- new MongoCompatibilityError (
158
- `Server ${ server . name } , which reports wire version ${ serverWireVersion } , does not support collation`
159
- )
160
- ) ;
161
- return ;
162
- }
163
-
164
153
if ( this . writeConcern && this . hasAspect ( Aspect . WRITE_OPERATION ) && ! inTransaction ) {
165
154
Object . assign ( cmd , { writeConcern : this . writeConcern } ) ;
166
155
}
167
156
168
- if ( serverWireVersion >= SUPPORTS_WRITE_CONCERN_AND_COLLATION ) {
169
- if (
170
- options . collation &&
171
- typeof options . collation === 'object' &&
172
- ! this . hasAspect ( Aspect . SKIP_COLLATION )
173
- ) {
174
- Object . assign ( cmd , { collation : options . collation } ) ;
175
- }
157
+ if (
158
+ options . collation &&
159
+ typeof options . collation === 'object' &&
160
+ ! this . hasAspect ( Aspect . SKIP_COLLATION )
161
+ ) {
162
+ Object . assign ( cmd , { collation : options . collation } ) ;
176
163
}
177
164
178
165
if ( typeof options . maxTimeMS === 'number' ) {
179
166
cmd . maxTimeMS = options . maxTimeMS ;
180
167
}
181
168
182
169
if ( this . hasAspect ( Aspect . EXPLAINABLE ) && this . explain ) {
183
- if ( serverWireVersion < 6 && cmd . aggregate ) {
184
- // Prior to 3.6, with aggregate, verbosity is ignored, and we must pass in "explain: true"
185
- cmd . explain = true ;
186
- } else {
187
- cmd = decorateWithExplain ( cmd , this . explain ) ;
188
- }
170
+ cmd = decorateWithExplain ( cmd , this . explain ) ;
189
171
}
190
172
191
173
server . command ( this . ns , cmd , options , callback ) ;
0 commit comments