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

Embeded objects gets doubled [see description for the whole scenario]

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Ubuntu with LAMP. I am using Code Igniter.

      Description

      If you have the database structure as:
      'Group' Collection has 'tables' (ReferenceMany targetDocument="Documents\Table") and 'chairs' (ReferenceMany targetDocument="Documents\Chair").
      'Table' Collection has 'glasses' (EmbedMany targetDocument="Documents\Glass") and a name as (@String).
      'Chair' Collection has a name as (@String) and tablenames as (@Hash).
      'Glass' Collection has name as (@String).

      First, I simply add a glass to table and add that table to group. And create a chair and add it to group also.
      $dm = $this->doctrine->getDM();
      $group = new Group();
      $table = new Table();
      $chair = new Chair();
      $glass = new Glass();

      $group->tables[] = $table;
      $group->chairs[] = $chair;
      $table->glasses[] = $glass;

      $dm->persist($group);
      $dm->flush();
      *At this point the tablenames in 'Chair' collection is not entered.

      Now I call a function, which adds a new chair;
      function addChair()
      {
      $dm = $this->doctrine->getDM();
      $chair = new Chair();
      $group = $dm->createQuery('Documents\Group')
      ->where('name','group')
      ->getSingleResult();
      foreach($group->tables as $table)

      { $chair->tableNames[] = $table->name; }

      $group->chairs[] = $chair;
      $dm->persist($chair);
      $dm->flush();
      }

      and as mentioned I traverse on tables to get table names and add those name in a new 'Chair' Collection's tablenames (@Hash).

      Now in Db I have:
      a group with two chairs and a table (both Referenced).
      two chairs (one with an array of "tablenames" and one doesn't have "tablenames"),
      a table with "TWO" embedded glasses <<--this is very strange I never added another glass to table!!!!

      Note: As I call "addChair()" one more time the glasses in table get multiplied by two!!!
      Please fix this asap.
      Thanks
      Regards
      Ahsan

        Activity

        Hide
        Bulat Shakirzyanov added a comment -

        this should be resolved in the current trunk

        Show
        Bulat Shakirzyanov added a comment - this should be resolved in the current trunk

          People

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

            Dates

            • Created:
              Updated:
              Resolved: