diff --git a/packages/compass-schema-validation/src/modules/validation.js b/packages/compass-schema-validation/src/modules/validation.js index 23fc10fec02..9b1bc955568 100644 --- a/packages/compass-schema-validation/src/modules/validation.js +++ b/packages/compass-schema-validation/src/modules/validation.js @@ -471,9 +471,8 @@ export const saveValidation = (validation) => { 'schema-validation-saved' ); dataService.updateCollection( - namespace.database, + `${namespace.database}.${namespace.collection}`, { - collMod: namespace.collection, validator: savedValidation.validator, validationAction: savedValidation.validationAction, validationLevel: savedValidation.validationLevel diff --git a/packages/data-service/src/native-client.ts b/packages/data-service/src/native-client.ts index 0ad87107d9f..dc75b35fef3 100644 --- a/packages/data-service/src/native-client.ts +++ b/packages/data-service/src/native-client.ts @@ -1102,14 +1102,19 @@ class NativeClient extends EventEmitter { */ updateCollection( ns: string, - flags: Document, + // Collection name to update that will be passed to the collMod command will + // be derived from the provided namespace, this is why we are explicitly + // prohibiting to pass collMod flag here + flags: Document & { collMod?: never }, callback: Callback ): void { const collectionName = this._collectionName(ns); const db = this.client.db(this._databaseName(ns)); + // Order of arguments is important here, collMod is a command name and it + // should always be the first one in the object const command = { - ...flags, collMod: collectionName, + ...flags, }; db.command(command, (error, result) => { if (error) {