Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #808 from doctrine/fix-queryCommand

Fix CLI sandbox command DM helper and QueryCommand
  • Loading branch information...
commit 74b876083c2f3b066be37558d28c0a388df3a491 2 parents ed46e36 + 26a0562
@jmikola jmikola authored
View
16 lib/Doctrine/ODM/MongoDB/Tools/Console/Command/QueryCommand.php
@@ -77,9 +77,9 @@ protected function configure()
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
$dm = $this->getHelper('documentManager')->getDocumentManager();
- $query = json_decode($input->getArgument('query'));
- $cursor = $dm->getRepository($input->getArgument('class'))->findBy((array) $query);
- $cursor->hydrate((bool) $input->getOption('hydrate'));
+ $qb = $dm->getRepository($input->getArgument('class'))->createQueryBuilder();
+ $qb->setQueryArray((array) json_decode($input->getArgument('query')));
+ $qb->hydrate((bool) $input->getOption('hydrate'));
$depth = $input->getOption('depth');
@@ -92,7 +92,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
throw new \LogicException("Option 'skip' must contain an integer value");
}
- $cursor->skip((int) $skip);
+ $qb->skip((int) $skip);
}
if (($limit = $input->getOption('limit')) !== null) {
@@ -100,11 +100,11 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
throw new \LogicException("Option 'limit' must contain an integer value");
}
- $cursor->limit((int) $limit);
+ $qb->limit((int) $limit);
}
- $resultSet = $cursor->toArray();
-
- \Doctrine\Common\Util\Debug::dump($resultSet, $depth);
+ foreach ($qb->getQuery() as $result) {
+ \Doctrine\Common\Util\Debug::dump($result, $depth);
+ }
}
}
View
8 tools/sandbox/mongodb.php
@@ -7,6 +7,10 @@
$app = new Application('Doctrine MongoDB ODM', Version::VERSION);
+if (isset($helperSet)) {
+ $app->setHelperSet($helperSet);
+}
+
$app->addCommands(array(
new \Doctrine\ODM\MongoDB\Tools\Console\Command\QueryCommand(),
new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateDocumentsCommand(),
@@ -18,8 +22,4 @@
new \Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\UpdateCommand(),
));
-if (isset($helperSet)) {
- $app->setHelperSet($helperSet);
-}
-
$app->run();
Please sign in to comment.
Something went wrong with that request. Please try again.