Skip to content

fix non hydrated EagerCursor. #424

Closed
wants to merge 1 commit into from

3 participants

@jaypea
jaypea commented Oct 5, 2012

Map hydrate properties of EagerCursor to the same properties of its BaseCursor.
I was trying to speed some queries with this combination:
$qb = $this->doctrine->createQueryBuilder('collection_name')
->eagerCursor(true)
->hydrate(false);

It didn't work because the EagerCursor lost information about the hydration flag on its way.
This PR fixes this problem.

@jmikola jmikola commented on the diff Oct 5, 2012
lib/Doctrine/ODM/MongoDB/Query/Query.php
@@ -220,6 +220,7 @@ public function execute()
// Wrap odm cursor with EagerCursor if true
if ($this->query['eagerCursor'] === true) {
$results = new EagerCursor($results, $this->dm->getUnitOfWork(), $this->class);
+ $results->hydrate($this->hydrate);
@jmikola
Doctrine member
jmikola added a note Oct 5, 2012

Can you fix the indentation here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jmikola
Doctrine member
jmikola commented Oct 5, 2012

@jwage: I took a look at the ODM and base Query classes, and am a bit confused as to why we have two EagerCursor classes. Is that purely to encapsulate the hydration logic?

The ODM's EagerCursor mentions extending the base class, although it really doesn't:

/**
 * EagerCursor extends the default Doctrine\MongoDB\EagerCursor implementation.
 *
 * @since       1.0
 * @author      Jonathan H. Wage <jonwage@gmail.com>
 */
class EagerCursor implements \Doctrine\MongoDB\Iterator

I'm mainly curious if there are other flags that should be copied over to the EagerCursor constructed in the ODM's Query class, or if the hydrate flag is all that's important. The base Query class already wraps the cursor with its EagerCursor implementation in Doctrine\MongoDB\Query::prepareCursor().

@jwage
Doctrine member
jwage commented Oct 11, 2012

@jmikola The hydrate flag is specific to the ODM. We should probably copy over the hints too.

@jmikola
Doctrine member
jmikola commented Apr 1, 2013

Follow-up in #424.

@jmikola jmikola closed this Apr 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.