Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1968

CommitOrderCalculator fails to calculate right order for mixing one-to-many and one-to-one relations

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.0.7
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:

      Description

      I have 2 classes. Zone and Rotator.
      Zone relates to Rotator as One-to-Many. And Zone COULD realte to Rotator as One-to-One. Here is code snippet:

       
      class Zone
      {
          /**
           * @var integer $id
           *
           * @ORM\Column(name="id", type="integer")
           * @ORM\Id
           * @ORM\GeneratedValue(strategy="AUTO")
           */
          private $id;
      
          /**
           * @ORM\OneToMany(targetEntity="Rotator", mappedBy="zone", cascade={"persist", "remove", "merge"}, orphanRemoval=true)
           * @ORM\OrderBy({"id" = "ASC"})
           */
          private $rotators = array();
      
          /**
           * @var Rotator $mainRotator
           *
           * @ORM\OneToOne(targetEntity="Rotator")
           * @ORM\JoinColumn(name="mainRotatorId", referencedColumnName="id")
           */
          private $mainRotator;
      
          /**
           * @var int $mainRotatorId
           *
           * @ORM\Column(name="mainRotatorId", type="integer", nullable="true")
           */
          private $mainRotatorId;
      }
      
       
      class Rotator
      {
          /**
           * @var integer $id
           *
           * @ORM\Column(name="id", type="integer")
           * @ORM\Id
           * @ORM\GeneratedValue(strategy="AUTO")
           */
          private $id;
      
          /**
           * @var Zone $zone
           *
           * @ORM\ManyToOne(targetEntity="Zone")
           * @ORM\JoinColumn(name="zoneId", referencedColumnName="id")
           */
          private $zone;
      
          /**
           * @var int $zoneId
           *
           * @ORM\Column(name="zoneId", type="integer")
           */
          private $zoneId;
      }
      

      When I delete only Zone - calculator works fine. But it fails if I delete entity Site, that relates to Zone as one-to-many (and have a lot of other raltions, so I don't write it here).

      As I look through the code, I see CommitOrderCalculator doesn't distiguish mandatory many-to-one relation from optional one-to-one one.

      PS this code hadn't been changed since 2.0, so this bug should be reproducable for master.

        Activity

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            miptpatriot
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: