Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0.0ALPHA2
-
Fix Version/s: 1.0.0BETA2
-
Component/s: Persister
-
Labels:None
Description
After changing ordering of elements in collection, it is persisted incorrectly (with different ordering than expected).
Here is a test case:
/** @Document(collection="tests", db="tests") */ class doc { /** @Id */ protected $id; /** @EmbedMany(targetDocument="emb") */ protected $collection; function __construct($c) {$this->set($c);} function set($c) {$this->collection = $c;} function get() {return $this->collection;} } /** @EmbeddedDocument */ class emb { /** @String */ protected $val; function __construct($val) {$this->val = $val;} function get() {return $this->val;} } $collection = new ArrayCollection(array( new emb('0'), new emb('1'), new emb('2') )); // TEST CASE: $doc = new doc($collection); $dm->persist($doc); $dm->flush(); // place element '0' after '1' $collection = new ArrayCollection(array( $collection[1], $collection[0], $collection[2] )); $doc->set($collection); $dm->persist($doc); $dm->flush(); $dm->refresh($doc); foreach($doc->get() as $value) { echo $value->get() . "\n"; } // expecting: // 1 // 0 // 2 // getting: // 2 // 1 // 0
Is it an issue? Or is it supposed that ordering should be resolved in application code?
Hi, I think we should try and make it maintain the order. I will investigate.