doctrine / DoctrineMongoODMModule

Laminas Module for Doctrine MongoDB ODM
https://www.doctrine-project.org/projects/doctrine-mongo-odm-module.html
MIT License
83 stars 87 forks source link

Paginator does not work with Mongodb ODM > 1.0.0-beta10@dev #107

Closed MuntzMathias closed 9 years ago

MuntzMathias commented 9 years ago

Hi, DoctrineMongoODMModule/Paginator/Adapter/DoctrinePaginator does not work since version mongodb-odm:1.0.0-beta10

This is due to a change in the Doctrine/ODM/MongoDB/DocumentRepository, the "findBy" function does not return a MongoODM/Cursor but an Array.

In BETA 9

/**
     * Finds documents by a set of criteria.
     *
     * @param array        $criteria Query criteria
     * @param array        $sort     Sort array for Cursor::sort()
     * @param integer|null $limit    Limit for Cursor::limit()
     * @param integer|null $skip     Skip for Cursor::skip()
     * @return Cursor
     */
    public function findBy(array $criteria, array $sort = null, $limit = null, $skip = null)
    {
        return $this->uow->getDocumentPersister($this->documentName)->loadAll($criteria, $sort, $limit, $skip);
    }

In BETA 10

/**
     * Finds documents by a set of criteria.
     *
     * @param array        $criteria Query criteria
     * @param array        $sort     Sort array for Cursor::sort()
     * @param integer|null $limit    Limit for Cursor::limit()
     * @param integer|null $skip     Skip for Cursor::skip()
     *
     * @return array
     */
    public function findBy(array $criteria, array $sort = null, $limit = null, $skip = null)
    {
        return $this->getDocumentPersister()->loadAll($criteria, $sort, $limit, $skip)->toArray(false);
    }

There is a solution to use the latest version of mongo-ODM (ex: BETA11)?

Ocramius commented 9 years ago

Ping @jmikola - is this BC break known?

jmikola commented 9 years ago

This was changed in 1.0.0-BETA10. Changelog entry is here.

Relevant issue was doctrine/mongodb-odm#752. This BC break was done so that we properly conform to the ObjectRepository interface. You actually commented in the thread, but I won't fault you for not remembering :smile:

Ocramius commented 9 years ago

@jmikola E_TOO_MANY_PROJECTS. @MuntzMathias can you PR with a fix and a composer.json version constraint bump?

MuntzMathias commented 9 years ago

The composer.json is right, only the documentation Doctrine ODM Paginator is wrong, you must not use the repository "findAll" function but the createQueryBuilder.

Ocramius commented 9 years ago

@MuntzMathias consider opening a PR against the docs if you know what has to be changed...

Ocramius commented 9 years ago

See #108