Skip to content

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

Closed
@halaei

Description

@halaei

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions