-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(NODE-4936)!: remove unsupported options from db.command and admin.command #3775
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
eaa525e
fix(NODE-4936)!: remove unsupported options from db.command and admin…
nbbeeken 1db31c3
Merge branch 'main' into NODE-4936-remove-runCommand-options
nbbeeken fac17c9
refactor: use public in constructor args
nbbeeken 7746428
fix ts in tests
nbbeeken a3370de
fix: comment
nbbeeken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,55 @@ | ||
import type { BSONSerializeOptions, Document } from '../bson'; | ||
import { type Db } from '../db'; | ||
import { type TODO_NODE_3286 } from '../mongo_types'; | ||
import type { ReadPreferenceLike } from '../read_preference'; | ||
import type { Server } from '../sdam/server'; | ||
import type { ClientSession } from '../sessions'; | ||
import { type Callback, MongoDBNamespace } from '../utils'; | ||
import { CommandCallbackOperation, type OperationParent } from './command'; | ||
import { MongoDBNamespace } from '../utils'; | ||
import { AbstractOperation } from './operation'; | ||
|
||
/** @public */ | ||
export type RunCommandOptions = { | ||
/** Specify ClientSession for this command */ | ||
session?: ClientSession; | ||
/** The read preference */ | ||
readPreference?: ReadPreferenceLike; | ||
|
||
// The following options were "accidentally" supported | ||
// Since the options are generally supported through inheritance | ||
|
||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
willRetryWrite?: any; | ||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
omitReadPreference?: any; | ||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
writeConcern?: any; | ||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
explain?: any; | ||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
readConcern?: any; | ||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
collation?: any; | ||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
maxTimeMS?: any; | ||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
comment?: any; | ||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
retryWrites?: any; | ||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
dbName?: any; | ||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
authdb?: any; | ||
/** @deprecated This is an internal option that has undefined behavior for this API */ | ||
noResponse?: any; | ||
|
||
/** @internal Used for transaction commands */ | ||
bypassPinningCheck?: boolean; | ||
} & BSONSerializeOptions; | ||
|
||
/** @internal */ | ||
export class RunCommandOperation<T = Document> extends CommandCallbackOperation<T> { | ||
override options: RunCommandOptions; | ||
command: Document; | ||
|
||
constructor(parent: OperationParent | undefined, command: Document, options?: RunCommandOptions) { | ||
super(parent, options); | ||
this.options = options ?? {}; | ||
this.command = command; | ||
export class RunCommandOperation<T = Document> extends AbstractOperation<T> { | ||
constructor(parent: Db, public command: Document, public override options: RunCommandOptions) { | ||
super(options); | ||
this.ns = parent.s.namespace.withCollection('$cmd'); | ||
} | ||
|
||
override executeCallback( | ||
server: Server, | ||
session: ClientSession | undefined, | ||
callback: Callback<T> | ||
): void { | ||
const command = this.command; | ||
this.executeCommandCallback(server, session, command, callback); | ||
override async execute(server: Server, session: ClientSession | undefined): Promise<T> { | ||
this.server = server; | ||
return server.commandAsync(this.ns, this.command, { | ||
...this.options, | ||
readPreference: this.readPreference, | ||
session | ||
}) as TODO_NODE_3286; | ||
} | ||
} | ||
|
||
export class RunAdminCommandOperation<T = Document> extends RunCommandOperation<T> { | ||
constructor(parent: OperationParent | undefined, command: Document, options?: RunCommandOptions) { | ||
super(parent, command, options); | ||
this.ns = new MongoDBNamespace('admin'); | ||
export class RunAdminCommandOperation<T = Document> extends AbstractOperation<T> { | ||
constructor( | ||
public command: Document, | ||
public override options: RunCommandOptions & { | ||
noResponse?: boolean; | ||
bypassPinningCheck?: boolean; | ||
} | ||
) { | ||
super(options); | ||
this.ns = new MongoDBNamespace('admin', '$cmd'); | ||
} | ||
|
||
override async execute(server: Server, session: ClientSession | undefined): Promise<T> { | ||
this.server = server; | ||
return server.commandAsync(this.ns, this.command, { | ||
...this.options, | ||
readPreference: this.readPreference, | ||
session | ||
}) as TODO_NODE_3286; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 theRenameOperation
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.