QueryCommand not working #801

Closed
emri99 opened this Issue Feb 12, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@emri99

emri99 commented Feb 12, 2014

Unable to launch the QueryCommand; I get this error:

bin/console odm:query User {} 

PHP Fatal error:  Call to a member function hydrate() on a non-object in /blabla/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/QueryCommand.php on line 83
PHP Stack trace:
PHP   1. {main}() /blabla/bin/console:0
PHP   2. Symfony\Component\Console\Application->run() /blabla/bin/console:33
PHP   3. Symfony\Component\Console\Application->doRun() /blabla/vendor/symfony/console/Symfony/Component/Console/Application.php:121
PHP   4. Symfony\Component\Console\Application->doRunCommand() /blabla/vendor/symfony/console/Symfony/Component/Console/Application.php:191
PHP   5. Symfony\Component\Console\Command\Command->run() /blabla/vendor/symfony/console/Symfony/Component/Console/Application.php:881
PHP   6. Doctrine\ODM\MongoDB\Tools\Console\Command\QueryCommand->execute() /blabla/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:241

Fatal error: Call to a member function hydrate() on a non-object in /blabla/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/QueryCommand.php on line 83

Call Stack:
    0.0055     645624   1. {main}() /blabla/bin/console:0
    0.0370    5877248   2. Symfony\Component\Console\Application->run() /blabla/bin/console:33
    0.0419    6464952   3. Symfony\Component\Console\Application->doRun() /blabla/vendor/symfony/console/Symfony/Component/Console/Application.php:121
    0.0423    6464952   4. Symfony\Component\Console\Application->doRunCommand() /blabla/vendor/symfony/console/Symfony/Component/Console/Application.php:191
    0.0424    6465120   5. Symfony\Component\Console\Command\Command->run() /blabla/vendor/symfony/console/Symfony/Component/Console/Application.php:881
    0.0433    6466096   6. Doctrine\ODM\MongoDB\Tools\Console\Command\QueryCommand->execute() /blabla/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:241

Possible fix:

replace line 81

$cursor = $dm->getRepository($input->getArgument('class'))->findBy((array) $query);

with

$cursor = $dm->getRepository($input->getArgument('class'))->createQueryBuilder()->setQueryArray((array) $query)->getQuery()->execute();
@jmikola

This comment has been minimized.

Show comment
Hide comment
@jmikola

jmikola Feb 24, 2014

Member

@emri99: Thanks for reporting this. Please let me know if the referenced PR fixed your issue.

Member

jmikola commented Feb 24, 2014

@emri99: Thanks for reporting this. Please let me know if the referenced PR fixed your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment