Support priming references on non-hydrated results #468

Open
kevou84 opened this Issue Dec 22, 2012 · 7 comments

Projects

None yet

4 participants

kevou84 commented Dec 22, 2012

Hi all,

I'm trying to get raw results when using prime(true) option on referenced objects like this :

    $dm = $this->get('doctrine_mongodb')->getManager();
    $qb = $dm->createQueryBuilder('MyBundle:Document');
    $qb->field('documentSimpleReferences')->prime(true);
    $query = $qb->hydrate(false)->getQuery();
    // 2 larger queries are performed eagerly to fetch documents and documentSimpleReferences
    $results = $query->execute();

It triggers the following error message :

Warning: get_class() expects parameter 1 to be object, array given in C:\Users...\sf\vendor\doctrine\mongodb-odm\lib\Doctrine\ODM\MongoDB\Persisters\DocumentPersister.php line 522

It seems that hydration should occur before prime and is globally disabled by hydrate(false) option... Or something like that... Looks like you had issues upon this matter before : #300

DocumentPersister:primeCollection() works fine if hydration enabled, but I'd like a flat array as result...

Thanks for your feedback,

Owner
jwage commented Jan 16, 2013

I didn't intend to allow this functionality. I will throw an exception in this case.

kevou84 commented Jan 18, 2013

I felt it would've been interesting to get results as raw data in array while prime option allowed to retrieve referenced data as well... Do you see something wrong with this ?

Owner
jwage commented Jan 18, 2013

I don't see anything wrong with it, it's just not a supported feature right now.

kevou84 commented Jan 22, 2013

Alright, is there a way to declare this as a feature request instead of issue ?

Have just come across this issue. As of today, is there any way to get an array with referenced data?

Owner
jwage commented Aug 27, 2013

This feature has not been implemented.

Owner
jmikola commented Dec 6, 2013

I renamed this issue and applied the new-feature tag for tracking.

Recent changes in #717 should avoid any errors/exceptions, as the Query class will only attempt priming if hydration is enabled (even if priming was specified in using the Builder).

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