Skip to content

Conversation

@kyleburgess2025
Copy link
Contributor

@kyleburgess2025 kyleburgess2025 commented Dec 18, 2025

Backport of MONGOID-5899

…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 kyleburgess2025 changed the base branch from master to 9.0-stable December 18, 2025 17:30
@kyleburgess2025 kyleburgess2025 marked this pull request as ready for review December 18, 2025 17:30
@kyleburgess2025 kyleburgess2025 requested a review from a team as a code owner December 18, 2025 17:30
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 backports MONGOID-5899, which fixes a conflicting update error when accessing embedded documents using the attribute accessor ([] notation). The fix prevents incorrectly marking embedded relations as changed when accessed via bracket notation.

Key Changes:

  • Modified process_raw_attribute to check if an attribute is a relation before marking it as changed
  • Added test coverage for accessing embedded documents with the attribute accessor to ensure no conflicting update errors occur
  • Fixed a typo in an existing test context name ("modifiying" → "modifying")

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 relations as changed when accessed
spec/mongoid/attributes_spec.rb Added test case for embedded document access and corrected spelling in context name

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

@jamis jamis added the bug Fixes a bug, with no new features or broken compatibility label Dec 18, 2025
@kyleburgess2025 kyleburgess2025 changed the title Backport MONGOID-5899 MONGOID-5899 Write conflict error when accessing embedded documents via [] operator after direct DB update Dec 18, 2025
@kyleburgess2025 kyleburgess2025 merged commit 4dcdadd into mongodb:9.0-stable Dec 19, 2025
61 checks passed
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