-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Handle case of array of ObjectIDs correctly #1768
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
@henry701, tests failed in your PR, check please. Seems like breaking changes |
Will check when i can. Sorry for taking long, I didn't check that the broken tests weren't flagged before but should have. |
Ok. You can join to slack channel. Link here |
In case an array of ObjectId-formatted Strings enter this method, this converts them to ObjectIds so that the query succeeds. Happens when calling 'get' method for one-to-many relations.
By matching based on the value of the foreign key using 'In' in case it is an array, this achieves successful matching of one-to-many relationships.
So... For information, I also ran the tests on the master branch using the clover docker-compose setup ( |
Hello, We will need to wait PR #1923 which will fix failing ci. Thank you for your contribution! |
@henry701 merge actual master |
@henry701 Add test case to https://github.com/jenssegers/laravel-mongodb/blob/master/tests/RelationsTest.php so we are sure it works correctly |
So I was trying to reproduce the original problem using unit tests today but didn't manage to, yet. All the use cases i created worked with both versions of the code. I will probably use a manual test on the old version of my backend which was having this issue and debug the sent query to MongoDB again, but it will take a while. The problem involves Well, I guess that's a lesson learned the hard way: Always reproduce in an isolated manner before fixing something. When I have new updates regarding this issue, I will comment here again and update the branch. |
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.
Needs more tests
Hello, Please let us know when you've checked your issue and added tests of course. Closing for now. Thanks. |
In case an array of ObjectId-formatted Strings enter this method, this converts them to ObjectIds so that the query succeeds. Happens when calling 'get' method for one-to-many relations.