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

References to embedded document collections #554

Open
Bilge opened this issue Apr 7, 2013 · 5 comments
Open

References to embedded document collections #554

Bilge opened this issue Apr 7, 2013 · 5 comments

Comments

@Bilge
Copy link
Contributor

Bilge commented Apr 7, 2013

I'm not sure if this is officially supported by Doctrine, since it is not documented, but it works - with an error notice.

For example, if I have documents A and B where document B has an embedded document, E, I can design the mapping as follows:

/** @Document */
class A {
    /** @ReferenceMany(targetDocument="B", mappedBy="foo.bar") */
    private $whatever = [];
}

/** @Document */
class B {
    /** @EmbedMany(targetDocument="E") */
    private $foo = [];
}

/** @EmbeddedDocument */
class E {
     /** @ReferenceOne(targetDocument="A", inversedBy="whatever") */
    private $bar;
}

However, reading A::$whatever generates the following notice:

Notice: Undefined index: foo.bar in mongodb-odm/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php on line 709

Despite this, the document collection is retrieved correctly.

@Bilge
Copy link
Contributor Author

Bilge commented Jun 8, 2013

This doesn't work if class B has a binary ID and $bar is a discriminator reference. I'm not sure what the culprit is here, but the symptomns are that count(A::$whatever) will never be > 1. That is, at most only one item is loaded into the collection on the field with an embedded document mapping.

@Bilge Bilge changed the title References to embedded document fields References to embedded document collections Mar 17, 2014
@jmikola jmikola added this to the 1.0.0 milestone Mar 31, 2014
@malarzm malarzm modified the milestones: 1.x, 1.0.0 Jun 11, 2015
@alcaeus alcaeus modified the milestones: 1.x, 2.x Dec 22, 2017
@alcaeus alcaeus removed this from the 2.x milestone Aug 5, 2021
@stale
Copy link

stale bot commented Sep 6, 2021

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Issues that have not seen any activity in 30 days label Sep 6, 2021
@Bilge
Copy link
Contributor Author

Bilge commented Sep 6, 2021

Imagine thinking anyone cares about design flaws.

@stale stale bot removed the Stale Issues that have not seen any activity in 30 days label Sep 6, 2021
@alcaeus
Copy link
Member

alcaeus commented Sep 7, 2021

Imagine thinking anyone cares about Open Source being a joint effort.

@Bilge
Copy link
Contributor Author

Bilge commented Sep 7, 2021

Imagine thinking open source means other people work for you for free.

@doctrine doctrine locked as too heated and limited conversation to collaborators Sep 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants