[MODM-52] Changes of nested embedded collection are not persisted Created: 18/Aug/10  Updated: 18/Aug/10  Resolved: 18/Aug/10

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

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


When there is a nested EmbedMany collection, changes of this collection are not persisted when saving root document.

Maybe simpler to explain with a test case:

 * @MappedSuperClass
class container
    /** @String */
    protected $tmp = 'ensureSaved';

    /** @EmbedMany(targetDocument="emb", cascade="all", strategy="set") */
    protected $items = array();

    function __construct($items = null) {if($items) $this->items = $items;}
    function getItems() {return $this->items;}
    function getItem($index) {return $this->items[$index];}
    function removeItem($i) {unset($this->items[$i]);}

/** @EmbeddedDocument */
class emb extends container

/** @Document(db="tests", collection="tests") */
class doc extends container
    /** @Id */
    protected $id;

$emb = new emb(array(new emb(), new emb()));
$doc = new doc(array($emb));


// change nested embedded collection:
$before = count($doc->getItem(0)->getItems());


$after = count($doc->getItem(0)->getItems());
var_dump($before); // outputs 1
var_dump($after);  // outputs 2, but expecting 1

Comment by Vladimir Razuvaev [ 18/Aug/10 ]

I think it might be related to this comment, although not sure.

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

Thanks for the issue and test!

Fixed here http://github.com/doctrine/mongodb-odm/commit/3e71c6a6f99360d88c66043ff989d7671e2ded08

Generated at Tue Oct 06 10:51:07 EDT 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.