[MODM-48] Embedded document changes are ignored if it was empty before Created: 16/Aug/10  Updated: 17/Aug/10  Resolved: 17/Aug/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: Persister
Affects Version/s: None
Fix Version/s: 1.0.0BETA1

Type: Bug Priority: Major
Reporter: Vladimir Razuvaev Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   

Imaging the object in DB:

{
  "_id": "4c693f9f0f9d501c0d000000",
  "b": [
  ]
}

Then following code fails to update property "b":

/** @Document(db="tests", collection="tests") */
class a
{
    /** @Id */
    protected $id;

    /** @EmbedOne(targetDocument="b", cascade="all") */
    protected $b;

    function getId()  {return $this->id;}
    function getB()   {return $this->b;}
    function setB($b) {$this->b = $b;}
}

/** @EmbeddedDocument */
class b
{
    /** @String */
    protected $val;
    function setVal($val) {$this->val = $val;}
    function getVal() {return $this->val;}
}

$a = $dm->loadByID('a', '4c693f9f0f9d501c0d000000');
$a->getB()->setVal('test');

$dm->persist($a);
$dm->flush();
$dm->getUnitOfWork()->clear();

$a = $dm->loadByID('a', $a->getId());
$c = ('test' === $a->getB()->getVal());

var_dump($c); // expecting "true", but outputs false


 Comments   
Comment by Jonathan H. Wage [ 16/Aug/10 ]

Are you using the most recent version of mongo in git?

Comment by Vladimir Razuvaev [ 16/Aug/10 ]

Yes, just updated to today's version from git - got same results.

Comment by Jonathan H. Wage [ 17/Aug/10 ]

Thanks for the issue!

Fixed by http://github.com/doctrine/mongodb-odm/commit/c57cc9fbf279918edcafd03ab4562ed33b467323

Generated at Sat Apr 19 17:09:31 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.