Undefined index in DocumentPersister when priming query #293

Closed
bazo opened this Issue Apr 20, 2012 · 4 comments

Comments

Projects
None yet
4 participants

bazo commented Apr 20, 2012

on line 525, version ed789d7

Owner

jmikola commented Apr 20, 2012

That goes back to when @jwage implemented collection priming in 2da6e9c. The index used to read class metadata is the $fieldName argument of the method, which I assume would be a field on the collection itself. Can you be more specific about the error you're experiencing?

Perhaps the exception message along with pastes of the relevant models?

I have similar issue, maybe @bazo is referencing the same one.
You cannot prime any attributes in the embedded documents. For example, you have

class Product
{
    //...
    /**
     * @ODM\EmbedMany(targetDocument="AttributeValue")
     */
    private $attributeValues;
    //...
}

class AttributeValue
{
    //...
    /**
     * @ODM\ReferenceOne(targetDocument="Attribute")
     */
    private $attribute;
    //...
}

public function indexAction()
{
    $dm = $this->get('doctrine.odm.mongodb.document_manager');
    $qb = $dm->createQueryBuilder('Product')
            ->field('attributeValues.attribute')->prime(true)
        ;
    $products = $qb->getQuery()->execute();

    return array('products' => $products);
}

I mean the part ->field('attributeValues.attribute')->prime(true). Of course, Product has no such attribute. Is there some way to prime attributes in embedded documents? Is it to be supported in some later version?

ephrin commented Nov 26, 2013

Vote Up

Owner

jmikola commented Dec 6, 2013

Tracking this in #624 as a new feature request.

jmikola closed this Dec 6, 2013

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