Skip to content

chore(shell-api): add test and type updates for sort #2520

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 2 commits into from
Aug 21, 2025
Merged

Conversation

gagik
Copy link
Contributor

@gagik gagik commented Aug 20, 2025

Followed up from the driver update, tests to ensure the new sort option works.

@Copilot Copilot AI review requested due to automatic review settings August 20, 2025 11:20
@gagik gagik requested a review from a team as a code owner August 20, 2025 11:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds test coverage and type updates for the sort option in MongoDB's updateOne and replaceOne operations. The changes ensure that the shell API properly supports sorting to determine which document gets updated when multiple documents match the filter criteria.

  • Adds comprehensive integration tests for updateOne and replaceOne with sort options
  • Updates TypeScript type definitions to include the sort parameter
  • Updates JSDoc comments to document the new sort option

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/shell-api/src/integration.spec.ts Adds test cases verifying sort functionality for updateOne and replaceOne operations
packages/shell-api/src/collection.ts Updates type signature and documentation for updateOne method to include sort option
packages/service-provider-core/src/writable.ts Updates interface type definition to include sort option in updateOne method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@gagik gagik added the no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion) label Aug 20, 2025
@gagik gagik changed the title chore(shell-api): add test and type updates for sort chore(shell-api): add test and type updates for sort CLOUDP-336196 Aug 20, 2025
@gagik gagik changed the title chore(shell-api): add test and type updates for sort CLOUDP-336196 chore(shell-api): add test and type updates for sort Aug 20, 2025
@@ -319,7 +319,7 @@ export default interface Writable {
collection: string,
filter: Document,
update: Document,
options?: UpdateOptions,
options?: UpdateOptions & { sort?: Document },
Copy link
Contributor

Choose a reason for hiding this comment

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

I was about to say "shouldn't that just be added to UpdateOptions?" but then realised it is also used for updateMany. Wondering if we should have a type next to UpdateOptions wherever it is defined that's type UpdateOneOptions = UpdateOptions & { sort?: Document } rather.

Copy link
Contributor

Choose a reason for hiding this comment

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

But also shouldn't sort already be on an underlying driver type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is some weirdness from the driver: #2511 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should at least make an UpdateOneOptions on our end so this is contained once, but that's not blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for now I'd match what the driver does so we don't end up with our type system too deeply, also have some precedent for this (admittedly that was also done by me I believe..)

options: AggregateOptions & { explain: ExplainVerbosityLike }

@@ -930,7 +930,7 @@ export class Collection<
* @param {Object} filter - The filter.
* @param {Object} replacement - The replacement document for matches.
* @param {Object} options - The replace options.
* <upsert, writeConcern, collation, hint>
* <upsert, writeConcern, collation, hint, sort>
Copy link
Contributor

@lerouxb lerouxb Aug 21, 2025

Choose a reason for hiding this comment

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

Shouldn't sort be added to the options that replaceOne takes? Or is it already on there? I suppose there's a test so somehow it has to be working.

@gagik gagik merged commit b6c6734 into main Aug 21, 2025
128 of 135 checks passed
@gagik gagik deleted the gagik/sort-test branch August 21, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants