Skip to content
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

chunkById() does not work when _id is integer #1538

Closed
halaei opened this issue Jun 12, 2018 · 2 comments · Fixed by #1543
Closed

chunkById() does not work when _id is integer #1538

halaei opened this issue Jun 12, 2018 · 2 comments · Fixed by #1543

Comments

@halaei
Copy link
Contributor

halaei commented Jun 12, 2018

In order to reproduce, make a collection with documents having integer ids. Then run the following:

\DB::connection('mongodb')->enableQueryLog();
User::query()->chunkById(100, function ($collection) {
    dd($collection->count());
});
dd(\DB::connection('mongodb')->getQueryLog());

The expected behavior would be dumping the count of first chunk.
What actually happens is this query getting dumped:

users.find({"_id":{"$gt":"000000000000000000000000"}},{"sort":{"_id":1},"limit":100,"typeMap":{"root":"array","document":"array"}})

Apparently, no integer is less than '000000000000000000000000' in MongoDb.

A Related PR: #1317
ping @DFurnes
Any idea on how to fix this?

@halaei
Copy link
Contributor Author

halaei commented Jun 12, 2018

I think the related PR in laravel/framework fixes this as well. Just a need to delete a couple of lines after laravel 5.7 release.

@DFurnes
Copy link
Contributor

DFurnes commented Jun 12, 2018

Yep, removing that hack now that this is fixed in Laravel makes sense to me! 👍

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 a pull request may close this issue.

2 participants