-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle nested Pattern in Criteria equals #3615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Document leftDocument = (Document) left; | ||
Document rightDocument = (Document) right; | ||
|
||
return isEqual(leftDocument.values(), rightDocument.values()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An equality check for Map
-like types requires a comparison of keys and values. Right now, a document could yield equality if only the order of values is the same regardless of the key the values are assigned to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I totally missed that one. I fixed it now: the keys and the values are compared in the case of a Document
.
7f55001
to
9d74734
Compare
Thank you for your contribution. That's merged, polished, and backported now. |
The equals method of
Pattern
returns false if twoPatterns
are equal but are different instances. This is already handled in theequals
method ofCriteria
and works well. However, sometimes aPattern
can be nested in aBasicDBList
or in aDocument
or both, like in the case of a$or
operator.This PR fixes that: it enhances the
equals
method to manually compareBasicDBLists
andDocuments
using the customisEqual
method. I am not aware of any util that allow to compare 2 collections using a customisEqual
function so I had to implement it manually.Closes #3414