Skip to content

Fix wrong class metadata used if adding a reference using query builder#3004

Open
attrib wants to merge 1 commit intodoctrine:2.17.xfrom
attrib:2.17.x
Open

Fix wrong class metadata used if adding a reference using query builder#3004
attrib wants to merge 1 commit intodoctrine:2.17.xfrom
attrib:2.17.x

Conversation

@attrib
Copy link
Copy Markdown

@attrib attrib commented Apr 8, 2026

Q A
Type bug
BC Break no
Fixed issues

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 int

That 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 $or and 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.

@attrib
Copy link
Copy Markdown
Author

attrib commented Apr 9, 2026

Adapted failing test and fixed CS issues

Copy link
Copy Markdown
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It should be merged into 2.16.x as this is a bugfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants