Skip to content

When Copying Many Embed Subdocuments From One Document To Another the source Documents loses the subdocuments #1229

Closed
@ghost

Description

    public function testWhenCopyingManyEmbedSubDocumentsFromOneDocumentToAnotherWillNotAffectTheSourceDocument()
    {

        $test1 = new ChangeEmbeddedIdTest();

        $embedded = new EmbeddedDocumentWithId();
        $embedded->id = (string) new \MongoId();;
        $test1->embedMany = array($embedded);

        $this->dm->persist($test1);
        $this->dm->flush();

        $test2 = new ChangeEmbeddedIdTest();
        $test2->embedMany = $test1->embedMany; //using clone will work
        $this->dm->persist($test2);
        $this->dm->flush();

        //do some operations on test1
        $this->dm->persist($test1);
        $this->dm->flush();

        $this->dm->clear(); //get clean results from mongo
        $test1 = $this->dm->find(get_class($test1), $test1->id);

        $this->assertEquals(1, count($test1->embedMany));
    }

This bug was not present on 1.0.0-BETA11 but appears after 1.0.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions