Skip to content

Conversation

@vkarpov15
Copy link
Member

Fix #46

Summary

#46 points out that setting defaultLeanOptions: { getters: true } does apply getters even if lean is not set, which can be problematic.

Examples

@vkarpov15 vkarpov15 requested a review from Copilot May 12, 2025 20:14
Copy link
Contributor

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 pull request fixes an issue where getters were applied even when lean was false despite defaultLeanOptions specifying getters. The key changes are:

  • Add an explicit early return in applyGetters when lean is false.
  • Update the getter computation logic to rely on the guarantee that lean is enabled.
  • Extend test coverage to validate behavior with and without explicit lean options.

Reviewed Changes

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

File Description
test/index.test.js Updated test case description and added assertions for fix (#46).
index.js Added an early return for non-lean queries and removed extra optional chaining.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@vkarpov15 vkarpov15 merged commit 0878a39 into master May 12, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected $unset fields in getChanges() when using defaultLeanOptions.getters and not using .lean()

2 participants