Skip to content

Loading…

DDC-656: UnitOfWork::recomputeSingleEntityChangeSet does not preserve field order #5165

Closed
doctrinebot opened this Issue · 6 comments

2 participants

@doctrinebot

Jira issue originally created by user wizardz:

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

@doctrinebot

Comment created by @beberlei:

fixed format

@doctrinebot

Comment created by @beberlei:

how is this a bug?

@doctrinebot

Comment created by wizardz:

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

@doctrinebot

Comment created by @beberlei:

Updating priority to critical

@doctrinebot

Comment created by @beberlei:

fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.0-BETA3 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.