Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2494

Proxy getId not invoke convertToPHPValue on custom type

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      I have a custom type tinyint:
      https://gist.github.com/entering/3503d7458e5fbe2f6e02

      I was using it a lot and when I updated to doctrine 2.4 beta it break some stuff. At the time i turn all on smallint and solve the problem, now I had time to look into it.

      Example, entity Currency:

          /**
           * @var integer
           *
           * @ORM\Column(name="id", type="tinyint", nullable=false, options={"unsigned": true})
           * @ORM\Id
           * @ORM\GeneratedValue(strategy="AUTO")
           */
          protected $id;
      
          /**
           * @ORM\Column(name="temp", type="tinyint", nullable=false)
           */
          protected $temp;
      

      Entity Campaign:

          /**
           * @var Currency
           *
           * @ORM\ManyToOne(targetEntity="Currency", inversedBy="campaigns")
           * @ORM\JoinColumns({
           *   @ORM\JoinColumn(name="currency_id", referencedColumnName="id", nullable=false)
           * })
           */
          protected $currency;
      

      When i have this piece of code:

      var_dump($campaign->getCurrency()->getId());
      var_dump($campaign->getCurrency()->getTemp());
      

      I get:
      string(1) "1"
      int(5)

      If I turn id into small int:
      int(1)
      int(5)

      If I switch the order to:

      var_dump($campaign->getCurrency()->getTemp());
      var_dump($campaign->getCurrency()->getId());
      

      As expected:
      int(5)
      int(1)

      If I place a var_dump on convertToPHPValue I can see that is not being called on getId when getId is lazy.

      This looks like a bug introduced when getId started being lazy to save queries.

        Issue Links

          Activity

            People

            • Assignee:
              Fabio B. Silva
              Reporter:
              Eduardo Oliveira
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: