Doctrine MongoDB ODM
  1. Doctrine MongoDB ODM
  2. MODM-17

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

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major 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.

        Activity

        Hide
        Jonathan H. Wage added a comment -

        Seems to be working now.

        Show
        Jonathan H. Wage added a comment - Seems to be working now.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Pablo Godel
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: