Skip to content

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

Closed
wants to merge 7 commits into from
Closed

Handle case of array of ObjectIDs correctly #1768

wants to merge 7 commits into from

Conversation

henry701
Copy link

@henry701 henry701 commented Jun 7, 2019

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.

@Smolevich
Copy link
Contributor

@henry701, tests failed in your PR, check please. Seems like breaking changes

@henry701
Copy link
Author

henry701 commented Aug 8, 2019

Will check when i can. Sorry for taking long, I didn't check that the broken tests weren't flagged before but should have.

@Smolevich
Copy link
Contributor

Ok. You can join to slack channel. Link here

henry701 and others added 5 commits January 23, 2020 00:26
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.
@henry701
Copy link
Author

So... For information, I also ran the tests on the master branch using the clover docker-compose setup (docker-compose run --rm tests ./vendor/bin/phpunit --coverage-clover ./clover.xml) and the same tests that are failing on the current master branch are failing for my patch branch (class Scope not being found)...

@divine
Copy link
Contributor

divine commented Jan 23, 2020

So... For information, I also ran the tests on the master branch using the clover docker-compose setup (docker-compose run --rm tests ./vendor/bin/phpunit --coverage-clover ./clover.xml) and the same tests that are failing on the current master branch are failing for my patch branch (class Scope not being found)...

Hello,

We will need to wait PR #1923 which will fix failing ci.

Thank you for your contribution!

@Smolevich Smolevich self-requested a review January 23, 2020 11:21
@Smolevich
Copy link
Contributor

@henry701 merge actual master

@Smolevich Smolevich requested a review from jenssegers January 23, 2020 11:22
@Smolevich
Copy link
Contributor

@henry701 Add test case to https://github.com/jenssegers/laravel-mongodb/blob/master/tests/RelationsTest.php so we are sure it works correctly

@henry701
Copy link
Author

henry701 commented Feb 3, 2020

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.

Copy link
Contributor

@Smolevich Smolevich left a comment

Choose a reason for hiding this comment

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

Needs more tests

@divine
Copy link
Contributor

divine commented Feb 23, 2020

Hello,

Please let us know when you've checked your issue and added tests of course.

Closing for now.

Thanks.

@divine divine closed this Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants