Issue Details (XML | Word | Printable)

Key: MODM-17
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Jonathan H. Wage
Reporter: Pablo Godel
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Doctrine MongoDB ODM

Multiple array / object with same content/properties do not get persisted

Created: 17/Jun/10 10:55 AM   Updated: 19/Jul/10 05:13 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0.0ALPHA2


 Description  « Hide
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.



 All   Comments   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Jonathan H. Wage added a comment - 19/Jul/10 04:11 PM
Seems to be working now.