Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-656

UnitOfWork::recomputeSingleEntityChangeSet does not preserve field order

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA2
    • Fix Version/s: 2.0-BETA3
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      php 5.3.2, ubuntu 10.4

      Description

      XML

      <?xml version="1.0" encoding="utf-8"?>
      <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
          <entity name="Entities\Specification" table="specification">
              <field name="name" type="string" column="name" length="255"/>
              <field name="type" type="string" column="type"/>
              <id name="specificationId" type="integer" column="specification_id">
                  <generator strategy="AUTO"/>
              </id>
          </entity>
      </doctrine-mapping>
      

      Code

      $spec = new \Entities\Specification();
      $spec->setName('test1');
      $spec->setType('type1');
      $em->persist($spec);
      $em->getUnitOfWork()->computeChangeSet($em->getClassMetadata(get_class($spec)), $spec);
      $data1 = $em->getUnitOfWork()->getEntityChangeset($spec);
      $spec->setType('type2');
      $em->getUnitOfWork()->recomputeSingleEntityChangeSet($em->getClassMetadata(get_class($spec)), $spec);
      $data2 = $em->getUnitOfWork()->getEntityChangeset($spec);
      // data1 contains keys in correct order: name, type
      var_dump($data1);
      // data2 contains keys in reverse order: type, name
      var_dump($data2);
      

      I got this issue when was trying to change entity properties using onFlush event

        Activity

        Hide
        Benjamin Eberlei added a comment -

        fixed format

        Show
        Benjamin Eberlei added a comment - fixed format
        Hide
        Benjamin Eberlei added a comment -

        how is this a bug?

        Show
        Benjamin Eberlei added a comment - how is this a bug?
        Hide
        Andriy Savchenko added a comment -

        when you call $em->flush() values are inserted switched

        Show
        Andriy Savchenko added a comment - when you call $em->flush() values are inserted switched
        Hide
        Benjamin Eberlei added a comment -

        Updating priority to critical

        Show
        Benjamin Eberlei added a comment - Updating priority to critical
        Hide
        Benjamin Eberlei added a comment -

        fixed

        Show
        Benjamin Eberlei added a comment - fixed

          People

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

            Dates

            • Created:
              Updated:
              Resolved: