@@ -21,6 +21,8 @@ var inherits = require('util').inherits,
2121 SessionMixins = require ( './shared' ) . SessionMixins ,
2222 relayEvents = require ( '../utils' ) . relayEvents ;
2323
24+ const collationNotSupported = require ( '../utils' ) . collationNotSupported ;
25+
2426function getSaslSupportedMechs ( options ) {
2527 if ( ! options ) {
2628 return { } ;
@@ -748,9 +750,9 @@ Server.prototype.command = function(ns, cmd, options, callback) {
748750 // If we are not connected or have a disconnectHandler specified
749751 if ( disconnectHandler ( self , 'command' , ns , cmd , options , callback ) ) return ;
750752
751- // Check if we have collation support
752- if ( this . ismaster && this . ismaster . maxWireVersion < 5 && cmd . collation ) {
753- return callback ( new MongoError ( f ( ' server %s does not support collation' , this . name ) ) ) ;
753+ // error if collation not supported
754+ if ( collationNotSupported ( this , cmd ) ) {
755+ return callback ( new MongoError ( ` server ${ this . name } does not support collation` ) ) ;
754756 }
755757
756758 // Are we executing against a specific topology
@@ -837,9 +839,9 @@ Server.prototype.update = function(ns, ops, options, callback) {
837839 // If we are not connected or have a disconnectHandler specified
838840 if ( disconnectHandler ( self , 'update' , ns , ops , options , callback ) ) return ;
839841
840- // Check if we have collation support
841- if ( this . ismaster && this . ismaster . maxWireVersion < 5 && options . collation ) {
842- return callback ( new MongoError ( f ( ' server %s does not support collation' , this . name ) ) ) ;
842+ // error if collation not supported
843+ if ( collationNotSupported ( this , options ) ) {
844+ return callback ( new MongoError ( ` server ${ this . name } does not support collation` ) ) ;
843845 }
844846
845847 // Setup the docs as an array
@@ -872,9 +874,9 @@ Server.prototype.remove = function(ns, ops, options, callback) {
872874 // If we are not connected or have a disconnectHandler specified
873875 if ( disconnectHandler ( self , 'remove' , ns , ops , options , callback ) ) return ;
874876
875- // Check if we have collation support
876- if ( this . ismaster && this . ismaster . maxWireVersion < 5 && options . collation ) {
877- return callback ( new MongoError ( f ( ' server %s does not support collation' , this . name ) ) ) ;
877+ // error if collation not supported
878+ if ( collationNotSupported ( this , options ) ) {
879+ return callback ( new MongoError ( ` server ${ this . name } does not support collation` ) ) ;
878880 }
879881
880882 // Setup the docs as an array
0 commit comments