Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.0.0BETA2
-
Component/s: Persister
-
Labels:None
Description
After adding new entry to referenced collection of existing document, ODM generates invalid update query.
Here is a test case:
/** @Document(db="tests", collection="tests") */ class a { /** @Id */ protected $id; /** @ReferenceMany(targetDocument="b", cascade="all") */ protected $b; function __construct($b) {$this->b = new ArrayCollection($b);} function getB() {return $this->b;} } /** @Document(db="tests", collection="tests2") */ class b { /** @Id */ protected $id; /** @String */ protected $tmp; function __construct($v) {$this->tmp = $v;} } $a = new a(array(new b('first'))); $dm->persist($a); $dm->flush(); // flush causes notices $dm->refresh($a); $a->getB()->add(new b('second')); $dm->persist($a); $dm->flush(); $dm->refresh($a); print_r($a->getB()->toArray());
Expecting following output:
Array
(
[0] => b Object
(
[id:protected] => 4c7c9eea0f9d502005000000
[tmp:protected] => first
)
[1] => b Object
(
[id:protected] => 4c7c9eea0f9d502005020000
[tmp:protected] => second
)
)
But getting:
Array
(
[0] => b Object
(
[id:protected] => 4c7c9eea0f9d502005000000
[tmp:protected] => first
)
[1] => b Object
(
[id:protected] => 4c7c9eea0f9d502005000000
[tmp:protected] => first
)
[2] => b Object
(
[id:protected] => 4c7c9eea0f9d502005020000
[tmp:protected] => second
)
)
Issue Links
- duplicates
-
MODM-70
Updates of documents after read
-
here is a test case for it http://pastie.org/1136303