From 7acafe0061859c6ed4d897981f3a83ac47e10acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 13 Sep 2022 20:51:34 +0200 Subject: [PATCH 1/2] Fix invalid error message on hint with unacknowledged write --- src/operations/update.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/operations/update.ts b/src/operations/update.ts index 8dd1de3bb7..dad9afd8ae 100644 --- a/src/operations/update.ts +++ b/src/operations/update.ts @@ -110,7 +110,16 @@ export class UpdateOperation extends CommandOperation { const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0; if (unacknowledgedWrite) { if (this.statements.find((o: Document) => o.hint)) { - callback(new MongoCompatibilityError(`Servers < 3.4 do not support hint on update`)); + if (maxWireVersion(server) < 5) { + callback(new MongoCompatibilityError(`Servers < 3.4 do not support hint on update`)); + } else { + // TODO: https://jira.mongodb.org/browse/NODE-3541 + callback( + new MongoCompatibilityError( + `This Node.js driver do not support hint together with unacknowledged writes` + ) + ); + } return; } } From 93ddb5278ca5a59977796a132b8c19453db65029 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Mon, 26 Sep 2022 14:10:06 -0400 Subject: [PATCH 2/2] chore: misc changes --- src/operations/delete.ts | 3 ++- src/operations/update.ts | 12 ++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/operations/delete.ts b/src/operations/delete.ts index 0ce9d871de..a9bc3c6625 100644 --- a/src/operations/delete.ts +++ b/src/operations/delete.ts @@ -85,7 +85,8 @@ export class DeleteOperation extends CommandOperation { const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0; if (unacknowledgedWrite) { if (this.statements.find((o: Document) => o.hint)) { - callback(new MongoCompatibilityError(`Servers < 3.4 do not support hint on delete`)); + // TODO(NODE-3541): fix error for hint with unacknowledged writes + callback(new MongoCompatibilityError(`hint is not supported with unacknowledged writes`)); return; } } diff --git a/src/operations/update.ts b/src/operations/update.ts index dad9afd8ae..278a0b34b2 100644 --- a/src/operations/update.ts +++ b/src/operations/update.ts @@ -110,16 +110,8 @@ export class UpdateOperation extends CommandOperation { const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0; if (unacknowledgedWrite) { if (this.statements.find((o: Document) => o.hint)) { - if (maxWireVersion(server) < 5) { - callback(new MongoCompatibilityError(`Servers < 3.4 do not support hint on update`)); - } else { - // TODO: https://jira.mongodb.org/browse/NODE-3541 - callback( - new MongoCompatibilityError( - `This Node.js driver do not support hint together with unacknowledged writes` - ) - ); - } + // TODO(NODE-3541): fix error for hint with unacknowledged writes + callback(new MongoCompatibilityError(`hint is not supported with unacknowledged writes`)); return; } }