<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Thu Jun 20 10:38:48 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/DBAL-361/DBAL-361.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>[DBAL-361] [GH-213] fixed bug on schema comparator, prevent multiple rename candidates for a single original field</title>
                <link>http://www.doctrine-project.org/jira/browse/DBAL-361</link>
                <project id="10040" key="DBAL">Doctrine DBAL</project>
                        <description>&lt;p&gt;This issue is created automatically through a Github pull request on behalf of leedavis81:&lt;/p&gt;

&lt;p&gt;  Url: &lt;a href=&quot;https://github.com/doctrine/dbal/pull/213&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/dbal/pull/213&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Message:&lt;/p&gt;

&lt;p&gt;Starting with the following Entity&lt;br/&gt;
```&lt;br/&gt;
/**&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;@Table(name=&quot;user&quot;)&lt;/li&gt;
	&lt;li&gt;@Entity&lt;br/&gt;
 */&lt;br/&gt;
class User
{
    /**
     * @var integer $id
     * @Column(name=&quot;id&quot;, type=&quot;integer&quot;, length=4)
     * @Id
     * @GeneratedValue(strategy=&quot;IDENTITY&quot;)
     */
    private $id;

    /**
     * @var \DateTime $date_alerted_email
     * @Column(name=&quot;date_alerted&quot;, type=&quot;datetime&quot;, nullable=true)
     */
    private $date_alerted;
}
&lt;p&gt;```&lt;br/&gt;
Upon  making the following alterations (remove date_alerted, and add two additional columns of the same type but different names):&lt;br/&gt;
```&lt;br/&gt;
/**&lt;/p&gt;&lt;/li&gt;
	&lt;li&gt;@Table(name=&quot;user&quot;)&lt;/li&gt;
	&lt;li&gt;@Entity&lt;br/&gt;
 */&lt;br/&gt;
class User
{
    /**
     * @var integer $id
     * @Column(name=&quot;id&quot;, type=&quot;integer&quot;, length=4)
     * @Id
     * @GeneratedValue(strategy=&quot;IDENTITY&quot;)
     */
    private $id;

    /**
     * @var \DateTime $date_alerted_email
     * @Column(name=&quot;date_alerted_email&quot;, type=&quot;datetime&quot;, nullable=true)
     */
    private $date_alerted_email;
    
    /**
     * @var \DateTime $date_alerted_js
     * @Column(name=&quot;date_alerted_js&quot;, type=&quot;datetime&quot;, nullable=true)
     */
    private $date_alerted_js;
}
&lt;p&gt;```&lt;br/&gt;
The doctrine cli schema tool used to run the update (dump sql) produces the following result:&lt;br/&gt;
```&lt;br/&gt;
ALTER TABLE user CHANGE date_alerted date_alerted_js DATETIME DEFAULT NULL&lt;br/&gt;
```&lt;br/&gt;
Expected result:&lt;br/&gt;
```&lt;br/&gt;
ALTER TABLE message ADD date_alerted_js DATETIME DEFAULT NULL, CHANGE date_alerted date_alerted_email DATETIME DEFAULT NULL&lt;br/&gt;
```&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;ol&gt;
	&lt;li&gt;
	&lt;ol&gt;
		&lt;li&gt;What went wrong&lt;/li&gt;
	&lt;/ol&gt;
	&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Upon running diffTable($from, $to) in \Doctrine\DBAL\Schema\Comparator.php line 69 both new columns are added to the &quot;addedColumns&quot; array, and the one removed column is correctly present in the removedColumns array.&lt;/p&gt;

&lt;p&gt;The first iteration on detectColumnRenamings (line 272) puts the two NEW columns up as rename candidates as expected, however they share the original field name. &lt;/p&gt;

&lt;p&gt;When iterating over the rename candidates no further checks are done and these entries are added to the renamedColumns array. The last overwrites the original as they share the same array key and the original gets ignored. &lt;/p&gt;

&lt;p&gt;My change checks the renamedColumns array for the existence of the old column name. It only becomes a rename candidate if the original field hasn&apos;t already used previously. Otherwise it remains in the addedColumns array.&lt;/p&gt;

&lt;p&gt;In the example above these changes will produce 1 change column and 1 add column as expected.&lt;/p&gt;
</description>
                <environment></environment>
            <key id="14100">DBAL-361</key>
            <summary>[GH-213] fixed bug on schema comparator, prevent multiple rename candidates for a single original field</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="1">Fixed</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="beberlei">Benjamin Eberlei</reporter>
                        <labels>
                    </labels>
                <created>Thu, 4 Oct 2012 16:00:59 +0000</created>
                <updated>Wed, 1 May 2013 12:26:39 +0000</updated>
                    <resolved>Wed, 1 May 2013 12:26:39 +0000</resolved>
                                            <fixVersion>2.3.4</fixVersion>
                                        <due></due>
                    <votes>0</votes>
                        <watches>3</watches>
                        <comments>
                    <comment id="20040" author="leedavis81" created="Thu, 18 Apr 2013 08:29:20 +0000"  >&lt;p&gt;Is there anything else I need to do to get this to be merged? It&apos;s quite a frustrating issue that causes me to run an update twice to ensure changes to the DB have been correctly applied.&lt;/p&gt;

&lt;p&gt;This bug also affects the migrations tool.&lt;/p&gt;

&lt;p&gt;Pull request has been created &lt;a href=&quot;https://github.com/doctrine/dbal/pull/213&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/dbal/pull/213&lt;/a&gt; &lt;/p&gt;</comment>
                    <comment id="20148" author="doctrinebot" created="Wed, 1 May 2013 12:25:27 +0000"  >&lt;p&gt;A related Github Pull-Request &lt;span class=&quot;error&quot;&gt;&amp;#91;GH-213&amp;#93;&lt;/span&gt; was closed:&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/dbal/pull/213&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/dbal/pull/213&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>