Skip to content

Conversation

jamis
Copy link
Contributor

@jamis jamis commented Sep 15, 2025

Backport #6034 to 9.0-stable.

* Ensure reload properly handles instances where we create a new document, but set the ID to an existing one

* Fix misplaced spec
@Copilot Copilot AI review requested due to automatic review settings September 15, 2025 17:46
@jamis jamis requested a review from a team as a code owner September 15, 2025 17:46
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 fixes a bug in the Mongoid ORM where the reload method wasn't properly updating the new_record status of documents. When a new document instance is created with an existing ID and then reloaded, it should be marked as an existing record rather than a new one.

  • Sets new_record to false when successfully reloading a document that exists in the database
  • Adds comprehensive test coverage for the new behavior in different scenarios

Reviewed Changes

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

File Description
lib/mongoid/reloadable.rb Adds logic to set @new_record = false when document is successfully reloaded from database
spec/mongoid/reloadable_spec.rb Adds test cases to verify new_record status is properly updated during reload

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

@jamis jamis added the bug Fixes a bug, with no new features or broken compatibility label Sep 15, 2025
Copy link
Contributor

@alexbevi alexbevi left a comment

Choose a reason for hiding this comment

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

LGTM

@jamis jamis merged commit 615620f into mongodb:9.0-stable Sep 17, 2025
62 checks passed
@jamis jamis deleted the 5895-reload-update-new_record branch September 17, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes a bug, with no new features or broken compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants