Skip to content

refactor(NODE-7089): make AggregateOperation subclass ModernizedOperation #4608

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 1 commit into from
Aug 5, 2025

Conversation

baileympearson
Copy link
Contributor

@baileympearson baileympearson commented Aug 4, 2025

Description

What is changing?

I broke this PR out of #4609 because it got kinda large.

This PR refactors AggregateOperation to subclass ModernizedOperation. Along the way, I encountered issues with omitReadPreference - an option which is used by the server class to remove a read preference from a command. To make this work with the existing design, the buildOptions method would need to start taking a reference to the connection to determine the maxWireVersion when attaching this option.

I didn't like this approach and this option is only used for the AggregateOperation when there is a write stage and we are using wire version <9, so I refactored to remove this option.

After removing omitReadPreference, it became clear we no longer needed trySecondaryWrite, which is also only used for Aggregation operations but is present on all operation classes, only used to determine if we should set omitReadPreference to true, and is assigned the same value has AggregateOperation.hasWriteStage.

After that I had a circular dependency because execute_operation now imports a reference to AggregateOperation. I broke the circular dependency by removing ExplainableCursor from explain.ts.

Is there new documentation needed for these changes?

What is the motivation for this change?

Release Highlight

Fill in title or leave empty for no highlight

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

@baileympearson baileympearson marked this pull request as ready for review August 4, 2025 21:29
@baileympearson baileympearson requested a review from a team as a code owner August 4, 2025 21:29
@durran durran self-assigned this Aug 5, 2025
@durran durran added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Aug 5, 2025
@durran durran merged commit a8338ad into main Aug 5, 2025
28 of 31 checks passed
@durran durran deleted the NODE-7089 branch August 5, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants