From 042d7ade4408b26a7f94a88eb02144fc433b6ba7 Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Fri, 27 Aug 2021 16:52:22 +0200 Subject: [PATCH 1/4] fix(mongodb-data-service): Change merge order to restore pre-typescript method behavior --- packages/data-service/src/native-client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/data-service/src/native-client.ts b/packages/data-service/src/native-client.ts index 0ad87107d9f..e17d5e614ac 100644 --- a/packages/data-service/src/native-client.ts +++ b/packages/data-service/src/native-client.ts @@ -1108,8 +1108,8 @@ class NativeClient extends EventEmitter { const collectionName = this._collectionName(ns); const db = this.client.db(this._databaseName(ns)); const command = { - ...flags, collMod: collectionName, + ...flags, }; db.command(command, (error, result) => { if (error) { From e6a7206fa7f016d9e0919658c3dd49dbb4d03d62 Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Fri, 27 Aug 2021 18:01:39 +0200 Subject: [PATCH 2/4] fix(@mongodb-js/compass-schema-validation, mongodb-data-service): Pass full namespace to the updateCommand; Add comments explaining why the order of args is important --- .../compass-schema-validation/src/modules/validation.js | 3 +-- packages/data-service/src/native-client.ts | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) 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 e17d5e614ac..b81cd872e4e 100644 --- a/packages/data-service/src/native-client.ts +++ b/packages/data-service/src/native-client.ts @@ -1102,11 +1102,16 @@ 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 explicitly + 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 there, collMod is a command name and it + // should always be the first one in the object const command = { collMod: collectionName, ...flags, From ce9bc40d8b278101fd273a3ae874e0575ad4db37 Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 27 Aug 2021 09:06:01 -0700 Subject: [PATCH 3/4] chore(mongodb-data-service): One "explicitly" is more than enough --- packages/data-service/src/native-client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/data-service/src/native-client.ts b/packages/data-service/src/native-client.ts index b81cd872e4e..6ac2611caba 100644 --- a/packages/data-service/src/native-client.ts +++ b/packages/data-service/src/native-client.ts @@ -1104,7 +1104,7 @@ class NativeClient extends EventEmitter { ns: string, // 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 explicitly + // prohibiting to pass collMod flag here flags: Document & { collMod?: never }, callback: Callback ): void { From a9327f34887e5c21569792071531c8ca83bc8ebf Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 27 Aug 2021 09:15:31 -0700 Subject: [PATCH 4/4] chore: More typo fixes --- packages/data-service/src/native-client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/data-service/src/native-client.ts b/packages/data-service/src/native-client.ts index 6ac2611caba..dc75b35fef3 100644 --- a/packages/data-service/src/native-client.ts +++ b/packages/data-service/src/native-client.ts @@ -1110,7 +1110,7 @@ class NativeClient extends EventEmitter { ): void { const collectionName = this._collectionName(ns); const db = this.client.db(this._databaseName(ns)); - // Order of arguments is important there, collMod is a command name and it + // Order of arguments is important here, collMod is a command name and it // should always be the first one in the object const command = { collMod: collectionName,