Fix wrong class metadata used if adding a reference using query builder#3004
Open
attrib wants to merge 1 commit intodoctrine:2.17.xfrom
Open
Fix wrong class metadata used if adding a reference using query builder#3004attrib wants to merge 1 commit intodoctrine:2.17.xfrom
attrib wants to merge 1 commit intodoctrine:2.17.xfrom
Conversation
Author
|
Adapted failing test and fixed CS issues |
GromNaN
reviewed
Apr 9, 2026
Member
GromNaN
left a comment
There was a problem hiding this comment.
Thank you very much for reporting the bug and for providing a fix.
I’m not very familiar with this code part, do you have any thoughts on the question below?
GromNaN
approved these changes
Apr 9, 2026
Member
GromNaN
left a comment
There was a problem hiding this comment.
LGTM. It should be merged into 2.16.x as this is a bugfix.
SenseException
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
We noticed that when using a reference and then adding a complex expression afterwards. Inside the expression the class meta data of the reference object is used and not from the original document.
Added a tests to show this behaviour. Without the fix this will throw a fatal error
Object of class MongoDB\BSON\UTCDateTime could not be converted to intThat we have two fields with the same name on two models, but with different types is kinda a fuck up on our side. But I think the ODM still should support this.
If you do not use the
$orand do only a$gte, then it works without the fix. Or what we did in our case as a workaround, adding the equals after the expression.The fix is small, but getting the test to work was some work.