Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-809

Decimal type: not convert to double variable type

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Can't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Hi.

      The doctrine DBAL type "decimal" not convert value to "double" variable type in PHP. And if use events for control changes set, we have a changes for field.

      For example:

      /** Entity class **/
      /** @ORM\Column(name="field", type="decimal")
      private $field;
      
      /** Create entity **/
      $entity = new MyEntity();
      $entity->setField(1);
      $em->persist($entity);
      $em->flush($entity);
      
      /** Load entity **/
      $entity = $em->field('MyEntity', 1);
      var_dump($entity->getField()); // Then we have a string type
      $entity->setField(1); // Set a integer type
      

      Listener (onFlush):

      $em = $event->getEntityManager();
      $uow = $em->getUnitOfWork();
      
      $entity = $event->getEntity();
      $changes = $uow->getEntityChangeSet($entity);
      
      var_dump($changes); // Changes exists, because variable type not equals
      

      https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/DecimalType.php#L52

        Activity

        Hide
        Vitaliy Zhuk added a comment - - edited
        Show
        Vitaliy Zhuk added a comment - - edited Sorry, i not seen the attention section in docs: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#decimal

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Vitaliy Zhuk
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: