<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Tue May 21 19:08:29 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/si/jira.issueviews:issue-xml/DDC-1359/DDC-1359.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DDC-1359] Deleting and inserting with unique index</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1359</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;I&apos;m getting a database error when deleting and inserting records in a single unit of work. Consider this example:&lt;/p&gt;

&lt;p&gt;I have a user and user_info tables. user_info stores additional data about a user as a list of key-values.&lt;br/&gt;
user: id, name, email, password&lt;br/&gt;
user_info: id, user_id, info_key, info_value&lt;/p&gt;

&lt;p&gt;I created a unique index on user_info table: CREATE UNIQUE INDEX `user_info_key` ON `user_info` (`user_id` , `key` ) ;&lt;/p&gt;

&lt;p&gt;Each table is represented as an Entity class.&lt;/p&gt;

&lt;p&gt;Now, I run this code:&lt;br/&gt;
1. $user-&amp;gt;removeAllInfo(); // remove old entries&lt;br/&gt;
2. $user-&amp;gt;addInfo(&apos;first_name&apos;, &apos;John&apos;); // add new entries&lt;br/&gt;
3. $this-&amp;gt;em-&amp;gt;flush(); // save&lt;/p&gt;

&lt;p&gt;This causes MySQL error: &quot;Integrity constraint violation: 1062 Duplicate entry&quot;. Doctrine ORM first persists new entities and then deletes old entities.  I think the relevant code is at Doctrine/ORM/UnitOfWork :277-313. Everything works fine if I add flush() before line 2. Also, everything works fine if I change the index to non-unique.&lt;/p&gt;</description>
                <environment>MySQL</environment>
            <key id="12993">DDC-1359</key>
            <summary>Deleting and inserting with unique index</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="6" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/closed.png">Closed</status>
                    <resolution id="6">Invalid</resolution>
                                <assignee username="ocramius">Marco Pivetta</assignee>
                                <reporter username="rrafal@gmail.com">Rafal Radulski</reporter>
                        <labels>
                    </labels>
                <created>Fri, 2 Sep 2011 18:03:27 +0000</created>
                <updated>Sat, 9 Feb 2013 21:01:33 +0000</updated>
                    <resolved>Sat, 9 Feb 2013 21:01:32 +0000</resolved>
                            <version>2.0.7</version>
                                                <component>ORM</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>3</watches>
                        <comments>
                    <comment id="18247" author="ocramius" created="Sun, 8 Jul 2012 16:27:07 +0000"  >&lt;p&gt;I just got back to the UnitOfWork and (in latest master) it executes deletes as last operation (maybe to avoid cascades), and this is also documented.&lt;/p&gt;

&lt;p&gt;In my opinion, you should do the operation of computing the changeset on your `info` collection manually...&lt;/p&gt;</comment>
                    <comment id="19500" author="ocramius" created="Sat, 9 Feb 2013 21:01:33 +0000"  >&lt;p&gt;Invalid usage of collection API/object graph&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>