Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-4936)!: remove unsupported options from db.command and admin.command #3775

Merged
merged 5 commits into from
Jul 21, 2023

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Jul 19, 2023

Description

What is changing?

  • Removes unsupported options from db.command and admin.command

Internal:

  • Changes the inheritance of Run, Admin, Rename, CommandOperations classes
    • This fixes the accidental support of more options than should be supported
  • Unskip test for RC option in runCommand
  • Changes the construction of AdminCommand, unnecessary params
  • MongoClient close uses executeOperation b/c of the public options not supporting noResponse
Is there new documentation needed for these changes?

What is the motivation for this change?

Spec compliance

Release Highlight

db.command() and admin.command() unsupported options removed

These APIs allow for specifying a command BSON document directly, so the driver does not try to enumerate all possible commands that could be passed to this API in an effort to be as forward and backward compatible as possible. Supporting various server-side options that are encoded into the command document is difficult to correctly support for all use cases.

The db.command() and admin.command() APIs have their options types updated to accurately support options compatible on all commands that could be passed to either API. Perhaps most notably, readConcern and writeConcern options are no longer handled by the driver, users must attach these properties to the command that is passed to the .command() method.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket
  • Fill out release hightlight

@nbbeeken nbbeeken force-pushed the NODE-4936-remove-runCommand-options branch from 9c79022 to d35862e Compare July 19, 2023 18:23
@nbbeeken nbbeeken force-pushed the NODE-4936-remove-runCommand-options branch from d35862e to eaa525e Compare July 19, 2023 19:05
@nbbeeken nbbeeken marked this pull request as ready for review July 19, 2023 19:43
@baileympearson baileympearson self-assigned this Jul 19, 2023
@baileympearson baileympearson added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jul 19, 2023
Copy link
Contributor

@baileympearson baileympearson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're missing the following test from the kickoff:

Add WC not supported test to match the RC one. (The spec tests that RC/WC is not inherited from db/client, we supported it as a direct option)

@@ -49,7 +49,6 @@ const kSession = Symbol('session');
*/
export abstract class AbstractOperation<TResult = any> {
ns!: MongoDBNamespace;
cmd!: Document;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed because this no longer exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda, the xx! properties on this class are tech debt from the rapid TS conversion, we couldn't sort out which subclasses actually defined these and which didn't. Specifically cmd what only being attached by the RenameOperation so we don't need it defined on this super class. But also Rename is somewhat special in that most of our commands are build in the exec function, not in the constructor, so even Rename doesn't define this property anymore.

Comment on lines 20 to 28
override options: RunCommandOptions;
command: Document;

constructor(parent: OperationParent | undefined, command: Document, options?: RunCommandOptions) {
super(parent, options);
this.options = options ?? {};
constructor(parent: Db, command: Document, options: RunCommandOptions) {
super(options);
this.options = options;
this.command = command;
this.ns = parent.s.namespace.withCollection('$cmd');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
override options: RunCommandOptions;
command: Document;
constructor(parent: OperationParent | undefined, command: Document, options?: RunCommandOptions) {
super(parent, options);
this.options = options ?? {};
constructor(parent: Db, command: Document, options: RunCommandOptions) {
super(options);
this.options = options;
this.command = command;
this.ns = parent.s.namespace.withCollection('$cmd');
}
constructor(parent: Db, public command: Document, public override options: RunCommandOptions) {
super(options);
this.ns = parent.s.namespace.withCollection('$cmd');
}

optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@nbbeeken nbbeeken requested a review from baileympearson July 20, 2023 17:26
@baileympearson baileympearson added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Jul 20, 2023
@baileympearson baileympearson merged commit 52cd649 into main Jul 21, 2023
@baileympearson baileympearson deleted the NODE-4936-remove-runCommand-options branch July 21, 2023 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants