Skip to content

Conversation

@kyleburgess2025
Copy link
Contributor

No description provided.

@kyleburgess2025 kyleburgess2025 marked this pull request as ready for review December 17, 2025 20:42
@kyleburgess2025 kyleburgess2025 requested a review from a team as a code owner December 17, 2025 20:42
Copilot AI review requested due to automatic review settings December 17, 2025 20:42
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 PR fixes a write conflict error (MONGOID-5899) that occurred when accessing embedded documents using the [] operator after a direct database update. The issue was caused by the process_raw_attribute method incorrectly marking relation attributes as changed when they were accessed, even though they hadn't been modified by the user.

Key Changes:

  • Modified process_raw_attribute to check if an attribute is a relation before marking it as changed
  • Added regression test to verify that accessing embedded documents via [] after direct DB updates doesn't cause save conflicts

Reviewed changes

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

File Description
lib/mongoid/attributes.rb Added relation check to prevent marking embedded document attributes as changed on access
spec/mongoid/attributes_spec.rb Added test case to verify the fix prevents write conflict errors when accessing embedded documents

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kyleburgess2025 kyleburgess2025 merged commit 780b2fd into mongodb:master Dec 18, 2025
63 checks passed
@kyleburgess2025 kyleburgess2025 added the bug Fixes a bug, with no new features or broken compatibility label Dec 18, 2025
kyleburgess2025 added a commit to kyleburgess2025/mongoid that referenced this pull request Dec 18, 2025
…ia [] operator after direct DB update (mongodb#6076)

* Adds support for single hash input in nested attributes for has_many associations.

* Fixing write conflict error when using [] to access embedded document

* undoing accidental changes
kyleburgess2025 added a commit that referenced this pull request Dec 19, 2025
…ia [] operator after direct DB update (#6077)

* MONGOID-5899 Write conflict error when accessing embedded documents via [] operator after direct DB update (#6076)

* Adds support for single hash input in nested attributes for has_many associations.

* Fixing write conflict error when using [] to access embedded document

* undoing accidental changes

* Trigger workflows
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.

2 participants