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

Fix bug when priming references nested in embedded documents #1414

Closed
wants to merge 1 commit into from

Conversation

chapa
Copy link
Contributor

@chapa chapa commented May 26, 2016

Fix bug that occur when you have a schema like this :

/** @ODM\Document */
class Document
{
    /** @ODM\Id */
    public $id;

    /** @ODM\EmbedOne(targetDocument="Embedded") */
    public $embeddedDocument;
}

/** @ODM\EmbeddedDocument */
class Embedded
{
    /** @ODM\ReferenceMany(targetDocument="Referenced", name="referenced_documents") */
    public $referencedDocuments;
}

/** @ODM\Document */
class Referenced
{
    /** @ODM\Id */
    public $id;
}

And you execute a query like this :

$qb = $dm->createQueryBuilder('Document')
    ->field('embeddedDocument.referencedDocuments')->prim(true)
;
$documents = $qb->getQuery()->execute();

I think it also occur if you change @ODM\EmbedOne to @ODM\EmbedMany and/or @ODM\ReferenceMany to @ODM\ReferenceOne.
To be sure, I test it all in ReferencePrimerTest.php

…e a "name" attribute different from the field name
@malarzm malarzm added the Bug label May 26, 2016
@malarzm malarzm added this to the 1.0.6 milestone May 26, 2016
@malarzm
Copy link
Member

malarzm commented May 26, 2016

I love name/fieldName bugs, thanks @chapa for catching this!

@malarzm malarzm modified the milestones: 1.1, 1.0.6 May 29, 2016
malarzm added a commit that referenced this pull request May 30, 2016
@malarzm
Copy link
Member

malarzm commented May 30, 2016

Merged manually in 1fdf2c7, thanks @chapa!

@malarzm malarzm closed this May 30, 2016
@chapa
Copy link
Contributor Author

chapa commented May 30, 2016

You're welcome ! ;-)

@chapa
Copy link
Contributor Author

chapa commented Jun 24, 2016

Hey !

Sorry to bring out this closed PR, but I just notice I forgot to remove 3 lines of annotation there.
If anyone who is making a useful commit would like to remove them, he's welcome ;-)

@malarzm
Copy link
Member

malarzm commented Jun 25, 2016

Thanks for pointing that out! Luckily not big deal ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants