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

QueryCommand not working #801

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

QueryCommand not working #801

emri99 opened this issue Feb 12, 2014 · 1 comment

Comments

@emri99
Copy link

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
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants