Regression: Embedded documents with same _id but different values are now treated as identical after version 9.0.8 #6064
Unanswered
lucasDechenier
asked this question in
Q&A
Replies: 1 comment
-
|
Possibly related to: #5982 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
After upgrading from Mongoid 9.0.7 to 9.0.8, a breaking change occurred in how equality (
==) is handled for embedded documents.Previously, it was possible to store multiple embedded documents with the same
_idbut different values when a custom==method was defined.Starting in version 9.0.8 (after the changes related to [MONGOID-4889](https://jira.mongodb.org/browse/MONGOID-4889) and [PR #6010](#6010)), Mongoid now treats embedded documents with the same
_idas identical, ignoring any custom equality definitions.This results in previous behavior no longer being possible.
Steps to Reproduce
Expected Behavior
Both embedded documents should be present, because the
==method defines equality based on bothidandvalue.In previous versions (up to 9.0.7), the output was:
Actual Behavior
Since version 9.0.8, the second embedded document replaces the first one.
The output is now:
Mongoid treats documents with the same
_idas the same object, regardless of the custom==implementation.Question
Is there any supported way to restore the previous behavior where custom equality logic (
==) was respected for embedded documents?If not, is this change intended to be permanent, and should applications now avoid relying on custom equality methods for embedded document uniqueness?
Environment
Beta Was this translation helpful? Give feedback.
All reactions