Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.0.0ALPHA2
-
Component/s: None
-
Labels:None
Description
If I have a Collection field and try to add 2 values that are the same, the second value never gets saved to the document. Example code:
class User
{
/** @Id */
private $id;
/** @String */
private $name;
/** @Collection */
private $logs = array();
}
$o = $dm->findOne(':User', array('name' => $arguments['name']));
$found = true;
if (!$o) {
$found = false;
$o = new User();
}
$o->setName($arguments['name']);
$o->addLog( array('a' => 'b' ));
$dm->persist($o);
$dm->flush();
or a EmbeddedMany field, and try to add to add 2 objects with the same content the same thing happens:
class User
{
/** @Id */
private $id;
/** @String */
private $name;
/** @EmbedMany(targetDocument="UserLog") */
private $logs = array();
}
$o = $dm->findOne(':User', array('name' => $arguments['name']));
$found = true;
if (!$o) {
$found = false;
$o = new User();
}
$o->setName($arguments['name']);
$l = new UserLog();
$l->setMsg('Testing');
$o->addLog($l);
$dm->persist($o);
$dm->flush();
If I change $l->setMsg('Testing'.time());
then it adds all the instances.
Seems to be working now.