11import type { BSONSerializeOptions , Document } from '../bson' ;
2- import { MongoCompatibilityError , MongoInvalidArgumentError } from '../error' ;
2+ import { MongoInvalidArgumentError } from '../error' ;
33import { Explain , ExplainOptions } from '../explain' ;
44import type { Logger } from '../logger' ;
55import { ReadConcern } from '../read_concern' ;
@@ -18,8 +18,6 @@ import { WriteConcern, WriteConcernOptions } from '../write_concern';
1818import type { ReadConcernLike } from './../read_concern' ;
1919import { AbstractOperation , Aspect , OperationOptions } from './operation' ;
2020
21- const SUPPORTS_WRITE_CONCERN_AND_COLLATION = 5 ;
22-
2321/** @public */
2422export interface CollationOptions {
2523 locale : string ;
@@ -152,40 +150,24 @@ export abstract class CommandOperation<T> extends AbstractOperation<T> {
152150 options . omitReadPreference = true ;
153151 }
154152
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-
164153 if ( this . writeConcern && this . hasAspect ( Aspect . WRITE_OPERATION ) && ! inTransaction ) {
165154 Object . assign ( cmd , { writeConcern : this . writeConcern } ) ;
166155 }
167156
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 } ) ;
176163 }
177164
178165 if ( typeof options . maxTimeMS === 'number' ) {
179166 cmd . maxTimeMS = options . maxTimeMS ;
180167 }
181168
182169 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 ) ;
189171 }
190172
191173 server . command ( this . ns , cmd , options , callback ) ;
0 commit comments