<!--
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sun May 19 18:18:55 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/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project+%3D+DC+AND+resolution+%3D+Unresolved+AND+component+%3D+Relations+ORDER+BY+priority+DESC&tempMax=1000&field=key&field=summary
-->
<!-- If you wish to do custom client-side styling of RSS, uncomment this:
<?xml-stylesheet href="http://www.doctrine-project.org/jira/styles/jiraxml2html.xsl" type="text/xsl"?>
-->
<rss version="0.92">
    <channel>
        <title>Doctrine Project</title>
        <link>http://www.doctrine-project.org/jira/secure/IssueNavigator.jspa?reset=true&amp;jqlQuery=project+%3D+DC+AND+resolution+%3D+Unresolved+AND+component+%3D+Relations+ORDER+BY+priority+DESC</link>
        <description>An XML representation of a search request</description>
                <language>en-us</language>
                        <issue start="0" end="37" total="37"/>
                <build-info>
            <version>5.2.7</version>
            <build-number>850</build-number>
            <build-date>21-02-2013</build-date>
        </build-info>
<item>
            <title>[DC-860]  0  down vote  favorite    In some circumstances Doctrine_Core::getTable(&apos;%Name%&apos;) returns Doctrine_Table instance instead of %Name%Table one.</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-860</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;In some circumstances Doctrine_Core::getTable(&apos;%Name%&apos;) returns Doctrine_Table instance instead of %Name%Table one.&lt;br/&gt;
So custom %Name%Table&apos;s methods become unavailable. &lt;/p&gt;

&lt;p&gt;In order to give a demonstration of this improper behavior : here is a schema of small issue tracking system&lt;/p&gt;

&lt;p&gt;User:&lt;br/&gt;
  actAs: &lt;span class=&quot;error&quot;&gt;&amp;#91;Timestampable&amp;#93;&lt;/span&gt;&lt;br/&gt;
  tableName: issue_user&lt;br/&gt;
  columns:&lt;br/&gt;
    user_id:        &lt;/p&gt;
{ type: integer, primary: true, autoincrement: true }
&lt;p&gt;    user_name:      &lt;/p&gt;
{ type: string(255) }
&lt;p&gt;    user_role:      &lt;/p&gt;
{ type: enum, values: [worker, dispatcher, manager] }
&lt;p&gt;    managed_by:     &lt;/p&gt;
{ type: integer }
&lt;p&gt;    password:       &lt;/p&gt;
{ type: string(32) }
&lt;p&gt;    salt:           &lt;/p&gt;
{ type: string(32) }
&lt;p&gt;  relations:&lt;br/&gt;
    Manager:&lt;br/&gt;
      foreignAlias: Workers&lt;br/&gt;
      class: User&lt;br/&gt;
      local: managed_by&lt;br/&gt;
      foreign: user_id&lt;br/&gt;
      type: one&lt;br/&gt;
      foreignType: many&lt;/p&gt;

&lt;p&gt;Issue:&lt;br/&gt;
  actAs: &lt;span class=&quot;error&quot;&gt;&amp;#91;Timestampable&amp;#93;&lt;/span&gt;&lt;br/&gt;
  columns:&lt;br/&gt;
    issue_id:        &lt;/p&gt;
{ type: integer, primary: true, autoincrement: true }
&lt;p&gt;    from_ceh:        &lt;/p&gt;
{ type: string(255) }
&lt;p&gt;    from_name:       &lt;/p&gt;
{ type: string(255) }
&lt;p&gt;    from_phone:      &lt;/p&gt;
{ type: string(255) }
&lt;p&gt;    from_location:   &lt;/p&gt;
{ type: string(255) }
&lt;p&gt;    comp_name:       &lt;/p&gt;
{ type: string(255) }
&lt;p&gt;    comp_serial:     &lt;/p&gt;
{ type: string(255) }
&lt;p&gt;    comp_os:         &lt;/p&gt;
{ type: enum, values: [Win95, Win98, WinNT, WinME, Win2000, WinXP, Vista, Win7] }
&lt;p&gt;    issue_title:     &lt;/p&gt;
{ type: string(255) }
&lt;p&gt;    comment:         &lt;/p&gt;
{ type: string(255) }
&lt;p&gt;    owner_id:        &lt;/p&gt;
{ type: integer }
&lt;p&gt;    is_executed:     &lt;/p&gt;
{ type: bool }
&lt;p&gt;  relations:&lt;br/&gt;
    Owner:&lt;br/&gt;
      onDelete: CASCADE&lt;br/&gt;
      foreignAlias: Issues&lt;br/&gt;
      class: User&lt;br/&gt;
      local: owner_id&lt;br/&gt;
      foreign: user_id&lt;br/&gt;
      type: one&lt;br/&gt;
      foreignType: many&lt;/p&gt;

&lt;p&gt;When I just call Doctrine_Core::getTable(&apos;User&apos;) it returns UserTable instance, but if I call it after such a query:&lt;/p&gt;

&lt;p&gt;Doctrine_Query::create()&lt;br/&gt;
        -&amp;gt;select(&apos;u.user_id, ws.user_id, i.*&apos;)&lt;br/&gt;
        -&amp;gt;from(&apos;User u, u.Workers ws, ws.Issues i&apos;)&lt;br/&gt;
        -&amp;gt;where(&apos;u.user_id=&apos;, $manager_id)&lt;br/&gt;
        -&amp;gt;fetchArray();&lt;/p&gt;

&lt;p&gt;calling Doctrine_Core::getTable(&apos;User&apos;) returns Doctrine_Table instance&lt;/p&gt;</description>
                <environment>WinXP, Apache, PHP 5.2.14</environment>
            <key id="11888">DC-860</key>
            <summary> 0  down vote  favorite    In some circumstances Doctrine_Core::getTable(&apos;%Name%&apos;) returns Doctrine_Table instance instead of %Name%Table one.</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/blocker.png">Blocker</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="hongkildong">Hong Kil Dong</reporter>
                        <labels>
                    </labels>
                <created>Mon, 6 Sep 2010 11:49:01 +0000</created>
                <updated>Mon, 6 Sep 2010 12:13:35 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-952] Non-Equal Nest Relations Not Working - from &quot;Children&quot; side</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-952</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I&apos;ve copy &amp;amp; pasted example from &lt;a href=&quot;http://www.doctrine-project.org/projects/orm/1.2/docs/manual/defining-models/1_0#relationships:join-table-associations:self-referencing-nest-relations:non-equal-nest-relations&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/projects/orm/1.2/docs/manual/defining-models/1_0#relationships:join-table-associations:self-referencing-nest-relations:non-equal-nest-relations&lt;/a&gt; .&lt;br/&gt;
I&apos;ve created User backend module using doctrine:generate-admin backend User task. On how to reproduce the error:&lt;/p&gt;

&lt;p&gt;1. Add 3 User objects (A,B,C)&lt;br/&gt;
2. Open generated edit form for User A.&lt;br/&gt;
3. Set User B as Children from Children list and Save&lt;br/&gt;
4. Set User B and C as Chidren from Children list and Save&lt;/p&gt;

&lt;p&gt;As a result you will see only C set as Children, and strange situation in database : &lt;/p&gt;

&lt;p&gt;UserReference Table:&lt;/p&gt;

&lt;p&gt;parent_id  |  child_id&lt;br/&gt;
    pk_B      |    pk_B       (!!!)&lt;br/&gt;
    pk_A      |    pk_C&lt;/p&gt;
</description>
                <environment>Ubuntu 10.04 + PHP 5.3.3 + Symfony 1.4.8</environment>
            <key id="12278">DC-952</key>
            <summary>Non-Equal Nest Relations Not Working - from &quot;Children&quot; side</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/blocker.png">Blocker</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="pawelbaranski">Pawe&#322; Bara&#324;ski</reporter>
                        <labels>
                    </labels>
                <created>Mon, 3 Jan 2011 10:15:37 +0000</created>
                <updated>Thu, 24 Mar 2011 04:59:10 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Record</component>
                <component>Relations</component>
                        <due></due>
                    <votes>4</votes>
                        <watches>4</watches>
                        <comments>
                    <comment id="15111" author="pawelbaranski" created="Thu, 6 Jan 2011 09:41:02 +0000"  >&lt;p&gt;Same ticket on symfony trac because I&apos;m not sure whose fault is it &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://trac.symfony-project.org/ticket/9398&quot; class=&quot;external-link&quot;&gt;http://trac.symfony-project.org/ticket/9398&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also some new error path there&lt;/p&gt;</comment>
                    <comment id="15574" author="bigbadbassman" created="Thu, 24 Mar 2011 04:56:07 +0000"  >&lt;p&gt;Test Case of Non-Equal Self-Referencing Relations, based on #&lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-329&quot; title=&quot;Problem saving Self Referencing (Nest Relations)&quot;&gt;DC-329&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Failure occures in line 75 of the test case file. This should not happen!&lt;br/&gt;
Only the parent object is modified in line 73 and saving should not interfere with the relations.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10958" name="DC952TestCase.php" size="4075" author="bigbadbassman" created="Thu, 24 Mar 2011 04:56:07 +0000" />
                </attachments>
            <subtasks>
            <subtask id="12323">DC-958</subtask>
        </subtasks>
        </item>

<item>
            <title>[DC-313] Ordering m2m relationship with column from related table (with orderBy option)</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-313</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I find no way to define automatic orderBy in m2m relations with column not from reference table, but actual related table.&lt;/p&gt;

&lt;p&gt;E.g. BlogPost &amp;lt;= m2m through BlogPostCategory =&amp;gt; BlogCategory&lt;br/&gt;
I need BlogPost-&amp;gt;Categories ordered by BlogCategory.name&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;class BlogPost &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition()
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;title&apos;, &apos;string&apos;, 128);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;content&apos;, &apos;string&apos;);
    }
    
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp()
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasMany(&apos;BlogCategory as BlogCategories&apos;, array(&apos;local&apos; =&amp;gt; &apos;id_blog_post&apos;, &apos;foreign&apos; =&amp;gt; &apos;id_blog_category&apos;, &apos;refClass&apos; =&amp;gt; &apos;BlogPostCategory&apos;, &apos;orderBy&apos; =&amp;gt; &apos;name&apos;));        
    }
}

class BlogCategory &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition()
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;name&apos;, &apos;string&apos;, 128);
    }
    
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp()
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasMany(&apos;BlogPost as BlogPosts&apos;, array(&apos;local&apos; =&amp;gt; &apos;id_blog_category&apos;, &apos;foreign&apos; =&amp;gt; &apos;id_blog_post&apos;, &apos;refClass&apos; =&amp;gt; &apos;BlogPostCategory&apos;));
    }
}

class BlogPostCategory &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition()
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;id_blog_post&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(&apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;id_blog_category&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(&apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
    }
    
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp()
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasOne(&apos;BlogPost&apos;, array(&apos;local&apos; =&amp;gt; &apos;id_blog_post&apos;, &apos;foreign&apos; =&amp;gt; &apos;id&apos;, &apos;onDelete&apos; =&amp;gt; &apos;CASCADE&apos;));
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasOne(&apos;BlogCategory&apos;, array(&apos;local&apos; =&amp;gt; &apos;id_blog_category&apos;, &apos;foreign&apos; =&amp;gt; &apos;id&apos;, &apos;onDelete&apos; =&amp;gt; &apos;CASCADE&apos;));
    }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The resulting query contains doubled &apos;name&apos; column in ORDER BY clause, both from reference table and related table, e.g. ORDER BY t2.name, t3.name&lt;/p&gt;

&lt;p&gt;I tried putting the following code in BlogCategory::setTableDefinition() instead of attribute in relation definition in BlogPost record:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;option(&apos;orderBy&apos;, &apos;name&apos;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;but the result was the same.&lt;/p&gt;

&lt;p&gt;Maybe I&apos;m doing something wrong? Is there a possibility to define an alias, where to get column name from - in orderBy attribute?&lt;/p&gt;

&lt;p&gt;Thanks in advance.&lt;/p&gt;</description>
                <environment>php 5.3/win, doctrine 1.2 svn, ATTR_QUOTE_IDENTIFIER = true, ATTR_USE_DQL_CALLBACKS = true</environment>
            <key id="10546">DC-313</key>
            <summary>Ordering m2m relationship with column from related table (with orderBy option)</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/blocker.png">Blocker</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="mh">Maciej Ho&#322;yszko</reporter>
                        <labels>
                    </labels>
                <created>Wed, 2 Dec 2009 12:53:05 +0000</created>
                <updated>Fri, 18 Feb 2011 03:32:42 +0000</updated>
                                    <version>1.2.0</version>
                                                <component>Record</component>
                <component>Relations</component>
                        <due></due>
                    <votes>3</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="10969" author="mh" created="Wed, 2 Dec 2009 12:53:49 +0000"  >&lt;p&gt;Attached test case.&lt;/p&gt;</comment>
                    <comment id="11080" author="mh" created="Tue, 8 Dec 2009 12:59:05 +0000"  >&lt;p&gt;I find this issue as critical one now, because when I use e.g.&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;option(&apos;orderBy&apos;, &apos;name&apos;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;in a model&apos;s definition (not ref class), then when other model is related m2m with it, a query loading both of them with relations will fail because of name column duplicated in ref table.&lt;/p&gt;</comment>
                    <comment id="12740" author="suhock" created="Fri, 23 Apr 2010 05:18:13 +0000"  >&lt;p&gt;I am having the same issue with an equivalent test case. For some reason, the &lt;tt&gt;&apos;orderBy&apos;&lt;/tt&gt; option on the target of the join (set by calling the &lt;tt&gt;option()&lt;/tt&gt; function inside the &lt;tt&gt;setUp()&lt;/tt&gt; method of the model class, not the ref class) is being applied to the relation table. After digging through the 1.2.2 tag a bit, I found altering line 1319 of Query.php as follows seems to fix the problem (at least against my test cases):&lt;/p&gt;

&lt;p&gt;&lt;del&gt;&lt;tt&gt;if (isset($map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;relation&amp;#39;&amp;#93;&lt;/span&gt;)) {&lt;/tt&gt;&lt;/del&gt;&lt;br/&gt;
&lt;ins&gt;&lt;tt&gt;if (isset($map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;relation&amp;#39;&amp;#93;&lt;/span&gt;) &amp;amp;&amp;amp; $map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;relation&amp;#39;&amp;#93;&lt;/span&gt;-&amp;gt;getTable() === $map&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;table&amp;#39;&amp;#93;&lt;/span&gt;) {&lt;/tt&gt;&lt;/ins&gt;&lt;/p&gt;

&lt;p&gt;I&apos;ll do some more thorough testing and submit a patch if I find time.&lt;/p&gt;</comment>
                    <comment id="15332" author="bwegrzyn" created="Thu, 17 Feb 2011 09:45:31 +0000"  >&lt;p&gt;I had this issue as well. suhock&apos;s solution fixed it for me. It would be nice if this was merged in to a bug fix release of Doctrine 1.x.&lt;/p&gt;</comment>
                    <comment id="15336" author="suhock" created="Fri, 18 Feb 2011 03:32:42 +0000"  >&lt;p&gt;I ended up creating a new ticket, &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-651&quot; class=&quot;external-link&quot;&gt;DC-651&lt;/a&gt;, which addresses a more general problem with the orderBy feature. You should use the attached Ticket_DC651.patch instead, as I found the solution I provided here is not completely correct and does not pass all test cases.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10202" name="DC313TestCase.php" size="3659" author="mh" created="Wed, 2 Dec 2009 12:53:49 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-1050] Doctrine_Relation_ForeignKey ignores ATTR_COLL_KEY attribute</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1050</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Doctrine_Relation_ForeignKey::fetchRelatedFor() executes the following code at line 70:&lt;/p&gt;

&lt;p&gt;$coll = $this-&amp;gt;getTable()&lt;del&gt;&amp;gt;getConnection()&lt;/del&gt;&amp;gt;query($dql, $id);&lt;br/&gt;
$related = $coll&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;As you can see it accesses the first element by using index &quot;0&quot; in $coll and hence ignores a modified ATTR_COLL_KEY-setting, for instance:&lt;/p&gt;

&lt;p&gt;$this-&amp;gt;setAttribute(Doctrine_Core::ATTR_COLL_KEY, &apos;id&apos;);&lt;/p&gt;

&lt;p&gt;Fortunately I had two models (ForeignA and ForeignB) in my project which both have an one-to-one relation to a third model (Main). That helped me finding this bug which causes the following strange behavior:&lt;/p&gt;

&lt;p&gt;// program 1:&lt;/p&gt;

&lt;p&gt;$m = new Main();&lt;br/&gt;
$m-&amp;gt;name = &apos;M1&apos;;&lt;br/&gt;
$m-&amp;gt;setForeignA(new ForeignA()); // has ATTR_COLL_KEY changed to &apos;id&apos;&lt;br/&gt;
$m-&amp;gt;setForeignB(new ForeignB());&lt;br/&gt;
$m-&amp;gt;save();&lt;/p&gt;

&lt;p&gt;// program 2:&lt;/p&gt;

&lt;p&gt;$m = Doctrine_Core::getTable(&apos;M1&apos;)-&amp;gt;findOneBy(&apos;name&apos;, &apos;M1&apos;);&lt;br/&gt;
$m-&amp;gt;getForeignA()-&amp;gt;exists(); // false&lt;br/&gt;
$m-&amp;gt;getForeignB()-&amp;gt;exists(); // true&lt;/p&gt;

&lt;p&gt;-------------------------&lt;/p&gt;

&lt;p&gt;The big problem about this issue is that behavior is inconsistent. If you don&apos;t split the example above into two separate programs/processes you won&apos;t have problems, since Doctrine accesses the reference which was stored when calling save().&lt;/p&gt;

&lt;p&gt;You will get into trouble using functional tests in Symfony. Since there is only a single process for all requests I wasn&apos;t able to reproduce a problem caused by this bug which appeared in the production environment.&lt;/p&gt;

&lt;p&gt;-------------------------&lt;/p&gt;

&lt;p&gt;Edit:&lt;/p&gt;

&lt;p&gt;Doctrine_Connection::queryOne() is affected as well!&lt;/p&gt;

&lt;p&gt;A solution is to replace&lt;/p&gt;

&lt;p&gt;$coll = $this-&amp;gt;getTable()&lt;del&gt;&amp;gt;getConnection()&lt;/del&gt;&amp;gt;query($dql, $id);&lt;br/&gt;
$related = $coll&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;by&lt;/p&gt;

&lt;p&gt;$related = $this-&amp;gt;getTable()&lt;del&gt;&amp;gt;getConnection()&lt;/del&gt;&amp;gt;query($dql, $id)-&amp;gt;getFirst();&lt;/p&gt;</description>
                <environment>Windows 7 64Bit&lt;br/&gt;
PHP 5.3&lt;br/&gt;
Symfony 1.4</environment>
            <key id="13506">DC-1050</key>
            <summary>Doctrine_Relation_ForeignKey ignores ATTR_COLL_KEY attribute</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/critical.png">Critical</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="fishbone">Uli Hecht</reporter>
                        <labels>
                    </labels>
                <created>Tue, 6 Mar 2012 22:55:02 +0000</created>
                <updated>Wed, 7 Mar 2012 13:02:40 +0000</updated>
                                    <version>1.2.3</version>
                                <fixVersion>1.2.4</fixVersion>
                                <component>Attributes</component>
                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="17534" author="fishbone" created="Wed, 7 Mar 2012 13:02:40 +0000"  >&lt;p&gt;Suggested patch&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="11167" name="ForeignKey.php.patch" size="642" author="fishbone" created="Wed, 7 Mar 2012 13:02:40 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-925] missing hasOne() method-call in many-to-many relation</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-925</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Here&apos;s my YAML-file for the model: &lt;a href=&quot;http://pastie.org/1290649&quot; class=&quot;external-link&quot;&gt;http://pastie.org/1290649&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I&apos;m using the following command to build the whole model: symfony doctrine:build --all --and-load&lt;br/&gt;
By this command symfony will create the model using Doctrine.&lt;/p&gt;

&lt;p&gt;Please have a closer look at the class BaseTicketHasHardware: &lt;a href=&quot;http://pastie.org/1290737&quot; class=&quot;external-link&quot;&gt;http://pastie.org/1290737&lt;/a&gt;&lt;br/&gt;
If I compare it to the class BaseTicketHasNote I expect a class like this: &lt;a href=&quot;http://pastie.org/1290765&quot; class=&quot;external-link&quot;&gt;http://pastie.org/1290765&lt;/a&gt;&lt;br/&gt;
But Doctrine has created this class: &lt;a href=&quot;http://pastie.org/1290766&quot; class=&quot;external-link&quot;&gt;http://pastie.org/1290766&lt;/a&gt;&lt;/p&gt;</description>
                <environment>Debian Lenny&lt;br/&gt;
Apache 2.0&lt;br/&gt;
PHP 5.3.3-0.dotdeb.1&lt;br/&gt;
Symfony 1.4.8 - using Doctrine 1.2.x</environment>
            <key id="12097">DC-925</key>
            <summary>missing hasOne() method-call in many-to-many relation</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="romanb">Roman S. Borschel</assignee>
                                <reporter username="simonsimcity">Simon Schick</reporter>
                        <labels>
                    </labels>
                <created>Thu, 11 Nov 2010 16:49:56 +0000</created>
                <updated>Thu, 11 Nov 2010 16:49:56 +0000</updated>
                                                                    <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-888] Foreign key id columns do not respect ATTR_DEFAULT_IDENTIFIER_OPTIONS</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-888</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Some time ago Jon Wage suggested that one can override the 8-byte default integer type for IDs by setting Doctrine_Core::ATTR_DEFAULT_IDENTIFIER_OPTIONS in configureDoctrine (in a Symfony project), like this:&lt;/p&gt;

&lt;p&gt;  public function configureDoctrine(Doctrine_Manager $manager)&lt;/p&gt;
  {
    // Use 4-byte IDs for backwards compatibility with databases built on
    // Apostrophe 1.4, sfDoctrineGuard pre-5.0, etc. You don&apos;t need this for
    // a brand new site
    $options = $manager-&amp;gt;getAttribute(Doctrine_Core::ATTR_DEFAULT_IDENTIFIER_OPTIONS);
    $options[&apos;length&apos;] = 4;
    $manager-&amp;gt;setAttribute(Doctrine_Core::ATTR_DEFAULT_IDENTIFIER_OPTIONS, $options);
  }

&lt;p&gt;This works for primary key id columns. However it is not respected by foreign key id columns, which do not consult ATTR_DEFAULT_IDENTIFIER_OPTIONS.&lt;/p&gt;

&lt;p&gt;I looked at working around this using ATTR_DEFAULT_COLUMN_OPTIONS, however it is not type-specific. So if you set a length of 4 with that option, it applies not just to all integers but also to dates, datetimes, booleans and many other things that definitely should not be 4 bytes. &lt;/p&gt;

&lt;p&gt;The correct fix seems to be for foreign key id columns to respect ATTR_DEFAULT_IDENTIFIER_OPTIONS. &lt;/p&gt;

&lt;p&gt;Also, ATTR_DEFAULT_COLUMN_OPTIONS should probably let you specify different defaults for each column type as the length option is basically not usable in its current form. But that would not be a particularly clean solution to the foreign key id problem since limiting non-ID integers to 4 bytes should not be necessary.&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;* *&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The motivation for this bug report:&lt;/p&gt;

&lt;p&gt;The new stable release of sfDoctrineGuardPlugin (for Symfony) does not specify an integer size as it formerly did, so the size of integers now defaults to 8 bytes. This breaks backwards compatibility with existing code that adds foreign key relationships to sfGuard objects like sfGuardUser, etc. Creating migrations to deal with changing this across all tables involved is quite difficult (all foreign key indexes must be dropped and recreated - doctrine:migrations-diff is unable to figure it out, understandably). &lt;/p&gt;</description>
                <environment>Any</environment>
            <key id="12006">DC-888</key>
            <summary>Foreign key id columns do not respect ATTR_DEFAULT_IDENTIFIER_OPTIONS</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="boutell">Tom Boutell</reporter>
                        <labels>
                    </labels>
                <created>Wed, 13 Oct 2010 12:52:51 +0000</created>
                <updated>Wed, 13 Oct 2010 13:03:15 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Migrations</component>
                <component>Relations</component>
                <component>Schema Files</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-880] Versionable + I18n creates additional migration with irrelevant data</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-880</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;First run of generate-migrations-diff and migrate creates 2 migration diff files. First one for new tables, second one for new indexes and foreign keys. Than if I run generate-migrations-diff again another version is created although nothing was changed and following is inside:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;1st entry tries to drop a foreign key never been created and not existing in file&lt;/li&gt;
	&lt;li&gt;next entry tries to create a foreign key already existing&lt;/li&gt;
	&lt;li&gt;3rd entry tries to create an existing index&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;After a long try and errorI found out that it&apos;s only happening with I18n plus Versionable behavior.&lt;/p&gt;

&lt;p&gt;As I already have spent much time for a report please have also a look at: &lt;a href=&quot;http://forum.diem-project.org/viewtopic.php?f=2&amp;amp;t=173&amp;amp;sid=5e0e3349c0e15a169bc9990a3104b3f6#p465&quot; class=&quot;external-link&quot;&gt;http://forum.diem-project.org/viewtopic.php?f=2&amp;amp;t=173&amp;amp;sid=5e0e3349c0e15a169bc9990a3104b3f6#p465&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As I&apos;m quite new to Doctrine and Symfony systems I cannot get further, but willing for more investigation if just one could give me a hint where to start.&lt;/p&gt;</description>
                <environment>PHP 5.2, Symfony 1.4, Diem 5.1, Doctrine 1.2.2</environment>
            <key id="11982">DC-880</key>
            <summary>Versionable + I18n creates additional migration with irrelevant data</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="sanshao">Thomas</reporter>
                        <labels>
                    </labels>
                <created>Wed, 6 Oct 2010 14:37:39 +0000</created>
                <updated>Mon, 19 Sep 2011 08:20:21 +0000</updated>
                                    <version>1.2.4</version>
                                                <component>Behaviors</component>
                <component>I18n</component>
                <component>Migrations</component>
                <component>Relations</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="14551" author="andrewcoulton" created="Sun, 10 Oct 2010 20:50:17 +0000"  >&lt;p&gt;I think this is because the versionable behaviour doesn&apos;t define a table name in the Doctrine_Template_Versionable class. As a result, if using model prefixes, the prefixes are not discarded from the table names when the behaviour model classes are built. This means that the tables have different names to what is expected, so they have different index keys, so the indexes are dropped and recreated as part of the migration.&lt;/p&gt;

&lt;p&gt;I have committed unit tests and patch for this issue (which applies to Searchable also) to &lt;a href=&quot;http://github.com/acoulton/doctrine1/tree/DC-880&quot; class=&quot;external-link&quot;&gt;http://github.com/acoulton/doctrine1/tree/DC-880&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="16492" author="xdade" created="Mon, 19 Sep 2011 08:19:31 +0000"  >&lt;p&gt;I experienced the same problem in the latest version 1.2.4, and the patch proposed by Andrew Coulton solves the problem.&lt;br/&gt;
Why the fix is not included in official release?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-845] One of our Foreign Keys is not being inserted/passed</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-845</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;We are working on a symfony/doctrine project and have come to a near halt on development.&lt;/p&gt;

&lt;p&gt;We feel that now, it may be a bug/feature in doctrine, regarding foreign keys&lt;/p&gt;

&lt;p&gt;Part of our model includes a join table that references three different table. Below is a diagram of what the model looks like, and the relevant portion of our schema.yml is at the bottom.&lt;/p&gt;

&lt;p&gt;Image of our schema: &lt;a href=&quot;http://imgur.com/dfFYI.png&quot; class=&quot;external-link&quot;&gt;http://imgur.com/dfFYI.png&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have a form that contains a set of embedded forms that attempt to create a new Person entry and add rows to the join table, adding items to the PersonName table as needed.&lt;/p&gt;

&lt;p&gt;The form attempts to do this by creating and saving PersonName objects with NameType parameters, but are running into the problem of Doctrine not including that column when trying to do an insert into the join table.&lt;/p&gt;

&lt;p&gt;Part of the problem seems to be caused by the Doctrine_Connection_UnitOfWork::saveAssociations method:&lt;/p&gt;

&lt;p&gt;                foreach ($v-&amp;gt;getInsertDiff() as $r) &lt;/p&gt;
{
                    $assocRecord = $assocTable-&amp;gt;create();
                    $assocRecord-&amp;gt;set($assocTable-&amp;gt;getFieldName($rel-&amp;gt;getForeign()), $r);
                    $assocRecord-&amp;gt;set($assocTable-&amp;gt;getFieldName($rel-&amp;gt;getLocal()), $record);
                    $this-&amp;gt;saveGraph($assocRecord);
                }

&lt;p&gt;Are we correct in understanding that this means that Doctrine 1.2 does not support tables with multiple foreign keys in this scenario?&lt;/p&gt;


&lt;p&gt;Here is the relevant portion of schema.yml:&lt;/p&gt;

&lt;p&gt;agPerson: &lt;br/&gt;
  columns: &lt;br/&gt;
    id: &lt;br/&gt;
      primary: true &lt;br/&gt;
      type: integer(5) &lt;br/&gt;
      autoincrement: true &lt;br/&gt;
  relations: &lt;br/&gt;
    agPersonName: &lt;br/&gt;
      class: agPersonName &lt;br/&gt;
      refClass: agPersonMjAgPersonName &lt;br/&gt;
      local: person_id &lt;br/&gt;
      foreign: person_name_id &lt;br/&gt;
    agPersonNameType: &lt;br/&gt;
      class: agPersonNameType &lt;br/&gt;
      refClass: agPersonMjAgPersonName &lt;br/&gt;
      local: person_id &lt;br/&gt;
      foreign: person_name_type_id &lt;br/&gt;
agPersonNameType: &lt;br/&gt;
  columns: &lt;br/&gt;
    id: &lt;br/&gt;
      primary: true &lt;br/&gt;
      type: integer(2) &lt;br/&gt;
      autoincrement: true &lt;br/&gt;
    person_name_type: &lt;br/&gt;
      unique: true &lt;br/&gt;
      type: string(30) &lt;br/&gt;
      notnull: true &lt;br/&gt;
    app_display: &lt;br/&gt;
      default: 1 &lt;br/&gt;
      type: boolean &lt;br/&gt;
      notnull: true &lt;br/&gt;
  relations: &lt;br/&gt;
    agPerson: &lt;br/&gt;
      class: agPerson &lt;br/&gt;
      refClass: agPersonMjAgPersonName &lt;br/&gt;
      local: person_name_type_id &lt;br/&gt;
      foreign: person_id &lt;br/&gt;
    agPersonName: &lt;br/&gt;
      class: agPersonName &lt;br/&gt;
      refClass: agPersonMjAgPersonName &lt;br/&gt;
      local: person_name_type_id &lt;br/&gt;
      foreign: person_name_id &lt;br/&gt;
agPersonName: &lt;br/&gt;
  columns: &lt;br/&gt;
    id: &lt;br/&gt;
      primary: true &lt;br/&gt;
      type: integer(5) &lt;br/&gt;
      autoincrement: true &lt;br/&gt;
    person_name: &lt;br/&gt;
      unique: true &lt;br/&gt;
      type: string(64) &lt;br/&gt;
      notnull: true &lt;br/&gt;
  relations: &lt;br/&gt;
    agPerson: &lt;br/&gt;
      class: agPerson &lt;br/&gt;
      refClass: agPersonMjAgPersonName &lt;br/&gt;
      local: person_name_id &lt;br/&gt;
      foreign: person_id &lt;br/&gt;
    agPersonNameType: &lt;br/&gt;
      class: agPersonNameType &lt;br/&gt;
      refClass: agPersonMjAgPersonName &lt;br/&gt;
      local: person_name_id &lt;br/&gt;
      foreign: person_name_type_id &lt;br/&gt;
agPersonMjAgPersonName: &lt;br/&gt;
  columns: &lt;br/&gt;
    id: &lt;br/&gt;
      primary: true &lt;br/&gt;
      type: integer(5) &lt;br/&gt;
      autoincrement: true &lt;br/&gt;
    person_id: &lt;br/&gt;
      type: integer(5) &lt;br/&gt;
      notnull: true &lt;br/&gt;
    person_name_id: &lt;br/&gt;
      type: integer(5) &lt;br/&gt;
      notnull: true &lt;br/&gt;
    person_name_type_id: &lt;br/&gt;
      type: integer(2) &lt;br/&gt;
      notnull: true &lt;br/&gt;
    is_primary: &lt;br/&gt;
      type: boolean &lt;br/&gt;
      notnull: true &lt;br/&gt;
  indexes: &lt;br/&gt;
    UX_ag_person_mj_ag_person_name: &lt;br/&gt;
      fields: &lt;span class=&quot;error&quot;&gt;&amp;#91;person_name_id, person_name_type_id, person_id&amp;#93;&lt;/span&gt; &lt;br/&gt;
      type: unique &lt;br/&gt;
  relations: &lt;br/&gt;
    agPerson: &lt;br/&gt;
      local: person_id &lt;br/&gt;
      foreign: id &lt;br/&gt;
    agPersonName: &lt;br/&gt;
      local: person_name_id &lt;br/&gt;
      foreign: id &lt;br/&gt;
    agPersonNameType: &lt;br/&gt;
      local: person_name_type_id &lt;br/&gt;
      foreign: id &lt;br/&gt;
actAs: &lt;br/&gt;
  Timestampable: &lt;/p&gt;



&lt;p&gt;As a caveat: we&apos;ve noticed that sfdoctrineguard group table, has such a relationship:&lt;/p&gt;

&lt;p&gt;mysql&amp;gt; describe sf_guard_user_group;&lt;br/&gt;
&lt;ins&gt;-----------&lt;del&gt;&lt;/ins&gt;&lt;/del&gt;--------&lt;del&gt;&lt;ins&gt;&lt;/del&gt;----&lt;del&gt;&lt;/ins&gt;&lt;/del&gt;---&lt;del&gt;&lt;ins&gt;&lt;/del&gt;-------&lt;del&gt;&lt;/ins&gt;&lt;/del&gt;------+&lt;/p&gt;
&lt;table class=&apos;confluenceTable&apos;&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; Field      &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; Type     &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; Null &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; Key &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; Default &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; Extra &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&lt;ins&gt;-----------&lt;del&gt;&lt;/ins&gt;&lt;/del&gt;--------&lt;del&gt;&lt;ins&gt;&lt;/del&gt;----&lt;del&gt;&lt;/ins&gt;&lt;/del&gt;---&lt;del&gt;&lt;ins&gt;&lt;/del&gt;-------&lt;del&gt;&lt;/ins&gt;&lt;/del&gt;------+&lt;/p&gt;
&lt;table class=&apos;confluenceTable&apos;&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; user_id    &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; int(11)  &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; NO   &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; PRI &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; 0       &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; group_id   &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; int(11)  &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; NO   &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; PRI &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; 0       &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; created_at &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; datetime &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; NO   &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; NULL    &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; updated_at &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; datetime &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; NO   &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt; NULL    &lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&lt;ins&gt;-----------&lt;del&gt;&lt;/ins&gt;&lt;/del&gt;--------&lt;del&gt;&lt;ins&gt;&lt;/del&gt;----&lt;del&gt;&lt;/ins&gt;&lt;/del&gt;---&lt;del&gt;&lt;ins&gt;&lt;/del&gt;-------&lt;del&gt;&lt;/ins&gt;&lt;/del&gt;------+&lt;/p&gt;


&lt;p&gt;i.e. IT has two foreign keys taken into account&lt;/p&gt;</description>
                <environment>Linux ubuntu 2.6.31-22-generic #63-Ubuntu SMP Thu Aug 19 00:23:50 UTC 2010 x86_64 GNU/Linux&lt;br/&gt;
PHP 5.2.10-2ubuntu6.4 with Suhosin-Patch 0.9.7 (cli) (built: Jan  6 2010 22:56:44) &lt;br/&gt;
mysql  Ver 14.14 Distrib 5.1.37, for debian-linux-gnu (x86_64) using  EditLine wrapper</environment>
            <key id="11840">DC-845</key>
            <summary>One of our Foreign Keys is not being inserted/passed</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="zelaz">charles wisniewski</reporter>
                        <labels>
                    </labels>
                <created>Fri, 27 Aug 2010 12:06:42 +0000</created>
                <updated>Fri, 27 Aug 2010 12:06:42 +0000</updated>
                                    <version>1.2.0</version>
                <version>1.2.1</version>
                <version>1.2.2</version>
                <version>1.2.3</version>
                                                <component>Record</component>
                <component>Relations</component>
                <component>Transactions</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-958] updating Models with Intra-Table Relations cascades strangely</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-958</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Sorry for the lengthy explanation, couldn&apos;t make it more straight forward:&lt;/p&gt;

&lt;p&gt;I have a model which is similiar to a nestet set but the tree structure needs to overlap:&lt;/p&gt;

&lt;p&gt;For Model A, every Object A1 can have multiple descendant objects A2 and in turn can be a descendant of multiple objects A0.&lt;/p&gt;

&lt;p&gt;Since I saw no way to do this with Nested-Set Relations (or Equal-Nested-Sets) I have set up my Model like this:&lt;/p&gt;

&lt;p&gt;modules:&lt;br/&gt;
  columns: ..&amp;lt;do not matter&amp;gt;&lt;br/&gt;
  relations:&lt;br/&gt;
    Children:&lt;br/&gt;
      class: modules&lt;br/&gt;
      refClass: modules_required&lt;br/&gt;
    Parents:&lt;br/&gt;
      class: modules&lt;br/&gt;
      refClass: modules_required&lt;/p&gt;

&lt;p&gt;modules_required:&lt;br/&gt;
  columns: &amp;lt;do not matter here, just 2 foreign key columns&amp;gt;&lt;br/&gt;
  relations:&lt;br/&gt;
    Children:&lt;br/&gt;
    Parents:&lt;/p&gt;

&lt;p&gt;I needed to specify the Relations on both tables, to use onDelete/onUpdate CASCADE rules. Generated Models look fine, just as intended.&lt;br/&gt;
(Every Class has many Children and has many Parents...)&lt;/p&gt;

&lt;p&gt;Now the strange part:&lt;br/&gt;
    When I update an object of modules (say id=18), Doctrine issues the following queries:&lt;br/&gt;
DELETE FROM modules_required WHERE (required_id = ? AND module_id IN (?, ?, ?, ?, ?)) - (18, 25, 26, 32, 34, 35) &lt;br/&gt;
// where 25 to 35 are CHILDREN of 18&lt;br/&gt;
UPDATE modules_required SET required_id = ? WHERE module_id = ? AND required_id = ? - (25, 25, 10)&lt;br/&gt;
UPDATE modules_required SET required_id = ? WHERE module_id = ? AND required_id = ? - (26, 26, 10)&lt;br/&gt;
UPDATE modules_required SET required_id = ? WHERE module_id = ? AND required_id = ? - (32, 32, 10)&lt;br/&gt;
UPDATE modules_required SET required_id = ? WHERE module_id = ? AND required_id = ? - (34, 34, 10)&lt;br/&gt;
UPDATE modules_required SET required_id = ? WHERE module_id = ? AND required_id = ? - (35, 35, 10)&lt;br/&gt;
UPDATE modules_required SET required_id = ? WHERE module_id = ? AND required_id = ? - (25, 25, 12)&lt;br/&gt;
//where 10 and 12 are PARENTS of 18&lt;br/&gt;
and somewhen, Doctrine encounters an MySQL ERROR because of the previous update marathon:&lt;br/&gt;
SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;23000&amp;#93;&lt;/span&gt;: Integrity constraint violation: 1062 Duplicate entry &apos;25-25&apos; for key &apos;PRIMARY&apos; &lt;/p&gt;

&lt;p&gt;The point is: &lt;br/&gt;
1. why is Doctrine trying to create self-referencing relations, and &lt;br/&gt;
2. why is it touching the relation at all, when i only did change some text fields in the object?&lt;/p&gt;

&lt;p&gt;Is there a better way to solve my problem?&lt;/p&gt;</description>
                <environment>PHP 5.3 / symfony 1.4.9</environment>
            <key id="12323">DC-958</key>
            <summary>updating Models with Intra-Table Relations cascades strangely</summary>
                <type id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/subtask_alternate.png">Sub-task</type>
                    <parent id="12278">DC-952</parent>
                        <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="bigbadbassman">Daniel Reiche</reporter>
                        <labels>
                    </labels>
                <created>Mon, 24 Jan 2011 11:42:09 +0000</created>
                <updated>Thu, 27 Jan 2011 04:21:44 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Behaviors</component>
                <component>Documentation</component>
                <component>Nested Set</component>
                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="15182" author="bigbadbassman" created="Tue, 25 Jan 2011 04:37:46 +0000"  >&lt;p&gt;forgot to add something: I have done a debug run, to see why these queries are created, when there was no data modified that related to these tables:&lt;/p&gt;

&lt;p&gt;Doctrine seems to handle my structure internally as a Nested-Set, although I have not specified an actAs: NestedSet or relations: equal: true statement in the model definition.&lt;br/&gt;
Is there a way to prevent symfony from misinterpreting this?&lt;/p&gt;

&lt;p&gt;This is not a nested set, as each object can have virtually any other object either as parent or as a child, and additionaly, parent relations can span multiple tree-levels:&lt;br/&gt;
Object 2 is parent of Object 3 and 6&lt;br/&gt;
Object 3 is parent of Object 4 and 5&lt;br/&gt;
Object 4 is parent of Object 6&lt;/p&gt;

&lt;p&gt;results in: Object 6 has parents 2 and 4 (where 4 has parent 3 and 3 has parent 2 in turn)&lt;/p&gt;

&lt;p&gt;This spanning relations seems to cause the guessed nested set to fail.&lt;/p&gt;

&lt;p&gt;I simply wanted to create an m:n Relation using a Reference table and the fact that both m and n are of the same class should not consider doctrine.&lt;/p&gt;</comment>
                    <comment id="15190" author="bigbadbassman" created="Wed, 26 Jan 2011 05:36:25 +0000"  >&lt;p&gt;related to #&lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-329&quot; title=&quot;Problem saving Self Referencing (Nest Relations)&quot;&gt;DC-329&lt;/a&gt;:&lt;br/&gt;
seems to be the same general problem as described there. Only in DC 1.2.3, doctrine tries to delete every child-relation for some unknown reason.&lt;/p&gt;

&lt;p&gt;also the h2aEqualable mentioned there does not work, because it does not prevent symfony from issueing the delete queries. It prevents only the UPDATE-Queries, and thus circumvents the MySQL-Error.&lt;/p&gt;

&lt;p&gt;Nevertheless, data is still corrupted after object save, thus not useable in production.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-1057] Inserts instead of updates for related objects</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1057</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Ok, so the object relations go like this:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Comparison
	&lt;ul&gt;
		&lt;li&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;1:N&amp;#93;&lt;/span&gt; Product (FK:comparison_id)
		&lt;ul&gt;
			&lt;li&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;1:N&amp;#93;&lt;/span&gt; Rules (FK:product_id, FK:option_id)&lt;/li&gt;
			&lt;li&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;1:N&amp;#93;&lt;/span&gt; Parameters (FK:product_id)
			&lt;ul&gt;
				&lt;li&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;1:N&amp;#93;&lt;/span&gt; Options (FK:parameter_id)&lt;/li&gt;
			&lt;/ul&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The testing code looks like following:&lt;/p&gt;

&lt;p&gt;== CODE START ==&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unable to find source-code formatter for language: php.&lt;/span&gt; Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml&lt;/div&gt;&lt;pre&gt;
$comp = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Application_Model_Comparison();

/* Filling $comp with data */

&lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ($i = 0; $i &amp;lt; 10; $i++) {

    $product = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Application_Model_Product();

    &lt;span class=&quot;code-comment&quot;&gt;// Options referenced in Rules
&lt;/span&gt;    $options = array();

    &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ($j = 0; $j &amp;lt; 10; $j++) {

        $param = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Application_Model_Parameter();

        &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ($k = 0; $k &amp;lt; 10; $k++) {

            $option = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Application_Model_Option();

            $param-&amp;gt;Options-&amp;gt;add($option);

            &lt;span class=&quot;code-comment&quot;&gt;// Register a single option &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; parameter
&lt;/span&gt;            &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (!isset($options[$j])) {
                $options[$j] = $option;
            }
        }

        $product-&amp;gt;Parameters-&amp;gt;add($param);
    }

    &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ($j = 0; $j &amp;lt; 10; $j++) {
        $rule = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Application_Model_Rule();

        $rule-&amp;gt;Option = $options[$j];
        $product-&amp;gt;Rules-&amp;gt;add($rule);
    }

    $comp-&amp;gt;Products-&amp;gt;add($product);
}

/**
 * The first save() goes nicely, all objects
 * are created (INSERTed)
 */ 

$comp-&amp;gt;save();

&lt;span class=&quot;code-comment&quot;&gt;// Remove every second product
&lt;/span&gt;$pCount = $comp-&amp;gt;Products-&amp;gt;count();

&lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ($i = 0; $i &amp;lt; $pCount; $i += 2) {
    $comp-&amp;gt;Products-&amp;gt;remove($i);
}

/**
 * Fails &lt;span class=&quot;code-keyword&quot;&gt;while&lt;/span&gt; trying to save
 *
 * Comparison-&amp;gt;Product-&amp;gt;Parameter-&amp;gt;Option
 * INSERT ... `parameter_id` cannot be NULL
 *
 * Comparison-&amp;gt;Product-&amp;gt;Rule
 * INSERT ... `product_id` cannot be NULL
 */

$comp-&amp;gt;save();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;== CODE END ==&lt;/p&gt;

&lt;p&gt;The first save() cleans up the relation information in the graph. All child objects are INSERTED instead of UPDATE.&lt;/p&gt;</description>
                <environment>linux, apache2, php 5.3</environment>
            <key id="13870">DC-1057</key>
            <summary>Inserts instead of updates for related objects</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="romanb">Roman S. Borschel</assignee>
                                <reporter username="grisha">Grzegorz Godlewski</reporter>
                        <labels>
                    </labels>
                <created>Fri, 20 Jul 2012 09:36:53 +0000</created>
                <updated>Fri, 20 Jul 2012 09:41:36 +0000</updated>
                                    <version>1.2.4</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-1056] Doctrine is not compatible with PHP 5.4 due to change in serialize() behaviour.</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1056</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;In PHP 5.4 there is a change in the way the object references are serialized:&lt;/p&gt;

&lt;p&gt;Quote:&lt;br/&gt;
&quot;Support for object references in recursive serialize() calls&lt;br/&gt;
Prior to PHP 5.4, object references where not saved in recursive serialize calls.&quot;&lt;/p&gt;

&lt;p&gt;This minor change, breaks down serialization of collections when column of type &quot;array&quot; is present - double serialization occurs.&lt;br/&gt;
I&apos;m attaching a patch fixing the issue.&lt;/p&gt;
</description>
                <environment>PHP 5.4+</environment>
            <key id="13751">DC-1056</key>
            <summary>Doctrine is not compatible with PHP 5.4 due to change in serialize() behaviour.</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="mg">Marcin Gil</reporter>
                        <labels>
                    </labels>
                <created>Mon, 4 Jun 2012 08:03:39 +0000</created>
                <updated>Mon, 28 Jan 2013 19:45:13 +0000</updated>
                                    <version>1.2.3</version>
                                                <component>Record</component>
                <component>Relations</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>3</watches>
                        <comments>
                    <comment id="18837" author="colin.darie" created="Mon, 15 Oct 2012 14:02:29 +0000"  >&lt;p&gt;I confirm for possible future readers: this patch works perfectly well. (cf github for several forks of doctrine with other bugfixes).&lt;/p&gt;</comment>
                    <comment id="19430" author="st3b3n" created="Sun, 27 Jan 2013 19:10:57 +0000"  >&lt;p&gt;Hi all, does somebody knows where can I get a copy of the Doctrine 1.2.4 version but running on php 5.4?&lt;br/&gt;
Thise version you&apos;re talking about&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;</comment>
                    <comment id="19431" author="mg" created="Mon, 28 Jan 2013 08:05:59 +0000"  >&lt;p&gt;I sent you URL to our private svn repo.&lt;/p&gt;</comment>
                    <comment id="19432" author="st3b3n" created="Mon, 28 Jan 2013 19:45:13 +0000"  >&lt;p&gt;Thanks, you&apos;ve saved mi life &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/biggrin.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="11197" name="Record.php.patch" size="1032" author="mg" created="Mon, 4 Jun 2012 13:59:32 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-447] Problem linking many-to-many relationships</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-447</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;Here&apos;s a small usage example of linking many-to-many relationships. The group is not linked with the user after calling link() as can be seen by comparing the group ids before and after the call.&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-style: solid;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;border-bottom-style: solid;&quot;&gt;&lt;b&gt;schema.yml&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;User:
  tableName: users
  columns:
    username:      { type: string(255), notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt; }
    email:         { type: string(255), notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt; }
  indexes:
    username_idx:
      fields: [username]
      type:   unique
    email_idx:
      fields: [email]
      type:   unique
  actAs: [Timestampable]
  relations:
    groups:
      class:    Group
      alias:    Groups
      refClass: UserGroupRelation

Group:
  tableName: groups
  columns:
    name: { type: string(255), notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt; }
  actAs: [Timestampable, NestedSet]
  relations:
    users:
      class:    User
      alias:    Users
      refClass: UserGroupRelation

UserGroupRelation:
  tableName: user_group_relations
  columns:
    user_id:  { type: integer, notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;, primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt; }
    group_id: { type: integer, notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;, primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt; }
  relations:
    Group:
      class:        Group
      foreignAlias: UserGroupRelations
      onDelete:     CASCADE
    User:
      class:        User
      foreignAlias: UserGroupRelations
      onDelete:     CASCADE
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;div class=&quot;code panel&quot; style=&quot;border-style: solid;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;border-bottom-style: solid;&quot;&gt;&lt;b&gt;test.php&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$u = Doctrine_Core::getTable(&apos;User&apos;)-&amp;gt;findOneByUsername(&apos;james&apos;);
$g = Doctrine_Core::getTable(&apos;Group&apos;)-&amp;gt;findOneByName(&apos;group&apos;);
var_dump($g[&apos;id&apos;]);
$current = array();
foreach ($u[&apos;UserGroupRelations&apos;] as $r) {
    $current[] = $r[&apos;group_id&apos;];
}
var_dump($current);
$u-&amp;gt;link(&apos;Groups&apos;, array($g[&apos;id&apos;]), &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;);
$u = Doctrine_Core::getTable(&apos;User&apos;)-&amp;gt;findOneByUsername(&apos;james&apos;);
$current = array();
foreach ($u[&apos;UserGroupRelations&apos;] as $r) {
    $current[] = $r[&apos;group_id&apos;];
}
var_dump($current);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;div class=&quot;code panel&quot; style=&quot;border-style: solid;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;border-bottom-style: solid;&quot;&gt;&lt;b&gt;Output&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;string(1) &lt;span class=&quot;code-quote&quot;&gt;&quot;2&quot;&lt;/span&gt;
array(3) {
  [0]=&amp;gt;
  string(1) &lt;span class=&quot;code-quote&quot;&gt;&quot;1&quot;&lt;/span&gt;
  [1]=&amp;gt;
  string(1) &lt;span class=&quot;code-quote&quot;&gt;&quot;5&quot;&lt;/span&gt;
  [2]=&amp;gt;
  string(1) &lt;span class=&quot;code-quote&quot;&gt;&quot;6&quot;&lt;/span&gt;
}
array(3) {
  [0]=&amp;gt;
  string(1) &lt;span class=&quot;code-quote&quot;&gt;&quot;1&quot;&lt;/span&gt;
  [1]=&amp;gt;
  string(1) &lt;span class=&quot;code-quote&quot;&gt;&quot;5&quot;&lt;/span&gt;
  [2]=&amp;gt;
  string(1) &lt;span class=&quot;code-quote&quot;&gt;&quot;6&quot;&lt;/span&gt;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; </description>
                <environment>Windows Vista x86 SP2, PHP 5.2.x</environment>
            <key id="10773">DC-447</key>
            <summary>Problem linking many-to-many relationships</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="ree">Rytis Daugirdas</reporter>
                        <labels>
                    </labels>
                <created>Mon, 25 Jan 2010 08:57:18 +0000</created>
                <updated>Mon, 25 Jan 2010 09:00:18 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-443] Incorrect insert order in i18n entities</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-443</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;If the schema has an entity MyMain with all its fields i18n and an entity MySecondary related to MyMain and you try to create a new MySecondary item using Symfony forms you get an error.&lt;/p&gt;

&lt;p&gt;I think the error is doctrine and in i18n because if you remove a field from the i18n behavior (&lt;tt&gt;fields: &lt;span class=&quot;error&quot;&gt;&amp;#91;a,b,c,d&amp;#93;&lt;/span&gt;&lt;/tt&gt;, for example) all works ok.&lt;br/&gt;
I&apos;ve included a symfony project to help developpers replicate the error.&lt;/p&gt;

&lt;p&gt;My Schema&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
MyMain:
  actAs:
    I18n:
      fields: [a,b,c,d, e]
  columns:
    a:  { type: string(255), notnull: true }
    b:  { type: string(255), notnull: true }
    c:  string
    d:  string
    e:  string

MySecondary:
  columns:
    my_main_id:  integer
    a:        string(255)
    b:        string(255)
  relations:
    MyMain:
      local: my_main_id
      foreign: id
      foreignType: one
      cascade: [delete]
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;And the form code&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;class MyMainForm extends BaseMyMainForm
{
  public function configure()
  {
    $this-&amp;gt;embedI18n(array(&apos;en&apos;, &apos;es&apos;));
  }
}

class MySecondaryForm extends BaseMySecondaryForm
{
  public function configure()
  {
    $this-&amp;gt;widgetSchema[&apos;my_main_id&apos;] = new sfWidgetFormInputHidden();
    $this-&amp;gt;embedRelation(&apos;MyMain as main_subform&apos;);
  }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And last the queries (and its order when you get the error)&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;INSERT INTO my_secondary (my_main_id, a, b) VALUES (?, ?, ?) - (, my_secondary[a], my_secondary[b])
INSERT INTO my_main_translation (id, lang, a, b, c, d, e) VALUES (?, ?, ?, ?, ?, ?, ?) - 
  (, en, my_secondary[main_subform][en][a], my_secondary[main_subform][en][b], my_secondary[main_subform][en][c], 
   my_secondary[main_subform][en][d], my_secondary[main_subform][en][e])
Error Doctrine_Connection_Mysql_Exception	SQLSTATE[23000]: Integrity constraint violation: 1048 Column &apos;id&apos; cannot be null 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment>Linux (2.6.21 kernel)&lt;br/&gt;
Apache/2.2.6&lt;br/&gt;
PHP 5.2.6&lt;br/&gt;
symfony version 1.4.1&lt;br/&gt;
doctrine 1.2</environment>
            <key id="10758">DC-443</key>
            <summary>Incorrect insert order in i18n entities</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="rodrigobb">Rodrigo Borrego Bernab&#233;</reporter>
                        <labels>
                    </labels>
                <created>Fri, 22 Jan 2010 11:29:13 +0000</created>
                <updated>Fri, 22 Jan 2010 11:29:13 +0000</updated>
                                                                    <component>I18n</component>
                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                    <attachment id="10308" name="i18nrelation_problem.tgz" size="27753" author="rodrigobb" created="Fri, 22 Jan 2010 11:29:13 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-442] Refined definition of relations regarding &quot;copy()&quot; cloning behaviour</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-442</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Doctrine&apos;s cloning feature is based on the Doctrine_Record::copy($deep = false) method, while the $deep param says whether to clone the related objects as well, or not.&lt;/p&gt;

&lt;p&gt;However, considering the perspective of the application logic, the functional need can also be stated as: &quot;I wish you to clone yourself, expecting you to know yourself which related objects you need to clone as well, or even to de-reference, or whatever is needed (e.g. to remove the relation).&quot;&lt;br/&gt;
For this, the $deep argument is somehow inaccurate, as it does not take into consideration the different meanings of the relations:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;some relations (namely aggregations in UML terminology) need that the cloned object shall still refer to the same object (like referenced by the cloned object)&lt;/li&gt;
	&lt;li&gt;some relations (namely compositions) need to clone the related objects as well, as the latter are owned by the main object.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Practical example: when cloning an invoice (Doctrine_Record), application logic expects that its invoice line items be cloned as well (compositions), but not the reference to the customer (cloning my customers this way will not increase my business &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/wink.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;.&lt;/p&gt;

&lt;p&gt;Thus it would be great if there were a means to specify the needed behaviour in the schema.yml etc.&lt;br/&gt;
Thinkable approach: extend the &quot;application-level cascade&quot; feature of Doctrine by adding a &quot;clone&quot; or &quot;copy&quot; parameters. Then the copy() method in Doctrine_Record will know which related objects to clone as well, or not, or to clear (null). I guess it&apos;s quite analogous to the &quot;delete&quot; cascade stuff.&lt;/p&gt;

&lt;p&gt;So far my proposal. In case it will find support, I will then be happy to provide an implementation proposal.&lt;/p&gt;</description>
                <environment></environment>
            <key id="10757">DC-442</key>
            <summary>Refined definition of relations regarding &quot;copy()&quot; cloning behaviour</summary>
                <type id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/newfeature.png">New Feature</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="rschumacher">Raphael Schumacher</reporter>
                        <labels>
                    </labels>
                <created>Thu, 21 Jan 2010 17:00:24 +0000</created>
                <updated>Wed, 10 Feb 2010 06:02:00 +0000</updated>
                                    <version>1.2.0</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-436]  Change in 1.2 to Doctrine_Event::skipOperation() functionality</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-436</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I have been using Doctrine 1.1.6.&lt;/p&gt;

&lt;p&gt;I have two related models, which are always saved together. In my application, save is called on class A and that save cascades to class B. I have a save listener which in some cases can intercept class A&apos;s save operation and call Doctrine_Event::skipOperation() to prevent class A from being persistently saved. However, in such cases, class B is still saved - the skipOperation() does not skip the entire operation, just class A&apos;s save operation, allowing subsequent operations to occur as normal.&lt;/p&gt;

&lt;p&gt;This is the desired functionality and has been working fine. However, I have just upgraded to 1.2.1. only to find that something has changed, causing the skipOperation() to skip the entire operation, therefore not saving class B when class A&apos;s listener interferes.&lt;/p&gt;

&lt;p&gt;I presume this is a bug. If not, what precisely has changed with skipOperation(), and how can I keep the traditional functionality? &lt;/p&gt;</description>
                <environment>Debian</environment>
            <key id="10744">DC-436</key>
            <summary> Change in 1.2 to Doctrine_Event::skipOperation() functionality</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="ondistantshores">Cameron Ross</reporter>
                        <labels>
                    </labels>
                <created>Mon, 18 Jan 2010 00:37:02 +0000</created>
                <updated>Wed, 10 Feb 2010 06:02:18 +0000</updated>
                                    <version>1.2.1</version>
                                <fixVersion>1.1.6</fixVersion>
                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-362] Doctrine fails to create correct table structure if model is named &quot;User&quot;</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-362</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When building models and database structure from YAML schema, Doctrine ignores the behaviors and relations on models if it is named &quot;User&quot;:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-none&quot;&gt;...

User:  
  actAs:
    Timestampable:
    Sluggable:
      unique: true
      fields: username
      canUpdate: true
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    company_id
      type: integer(4)
    timezone_id:
      type: integer(1)
    role_id:
      type: integer(1)
    email:
      type: string(255)
    username:
      type: string(255)
      unique: true
    password:
      type: string(40)
    firstname:
      type: string(255)
    lastname:
      type: string(255)
    last_login:
      type: datetime
  relations:
    Company:
      local: company_id
      foreign: id
    Timezone:
      local: timezone_id
      foreign: id
    Role:
      local: role_id
      foreign: id

...
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This creates the following table structure:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-sql&quot;&gt;CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `company_id` int(11) DEFAULT NULL,
  `timezone_id` tinyint(4) DEFAULT NULL,
  `role_id` tinyint(4) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `username` varchar(255) DEFAULT NULL,
  `password` varchar(40) DEFAULT NULL,
  `firstname` varchar(255) DEFAULT NULL,
  `lastname` varchar(255) DEFAULT NULL,
  `last_login` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The table structure is both missing foreign key constraints to Company, Timezone and Role. It is also missing columns &lt;tt&gt;updated_at&lt;/tt&gt; and &lt;tt&gt;created_at&lt;/tt&gt; for Timestampable behavior. The &lt;tt&gt;slug&lt;/tt&gt; column for Sluggable behavior is missing, as well.&lt;/p&gt;

&lt;p&gt;When looking at the BaseUser::setUp() method it looks as it is supposed to:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-none&quot;&gt;class BaseUser extends Doctrine_Record
{

    ....

    public function setUp()
    {
        parent::setUp();
        $this-&amp;gt;hasOne(&apos;Company&apos;, array(
             &apos;local&apos; =&amp;gt; &apos;company_id&apos;,
             &apos;foreign&apos; =&amp;gt; &apos;id&apos;));

        $this-&amp;gt;hasOne(&apos;Timezone&apos;, array(
             &apos;local&apos; =&amp;gt; &apos;timezone_id&apos;,
             &apos;foreign&apos; =&amp;gt; &apos;id&apos;));

        $this-&amp;gt;hasOne(&apos;Role&apos;, array(
             &apos;local&apos; =&amp;gt; &apos;role_id&apos;,
             &apos;foreign&apos; =&amp;gt; &apos;id&apos;));

        $timestampable0 = new Doctrine_Template_Timestampable();
        $sluggable0 = new Doctrine_Template_Sluggable(array(
             &apos;unique&apos; =&amp;gt; true,
             &apos;fields&apos; =&amp;gt; &apos;username&apos;,
             &apos;canUpdate&apos; =&amp;gt; true,
        ));
        $this-&amp;gt;actAs($timestampable0);
        $this-&amp;gt;actAs($sluggable0);
    }

    ....

}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So the only area where it goes wrong, is when generating the queries for creating the model tables. I don&apos;t know if the same problem appears with other model names, but it doesn&apos;t like models named &quot;User&quot;.&lt;/p&gt;

&lt;p&gt;If I rename the model to &quot;Person&quot; and rebuild, it all works perfectly as it should.&lt;/p&gt;</description>
                <environment>Mac OS X 10.6.2 (10C540) (Snow Leopard) with MAMP 1.8 bundle: &lt;br/&gt;
PHP Version: 5.2.10,&lt;br/&gt;
MySQL Version: 5.1.37&lt;br/&gt;
</environment>
            <key id="10623">DC-362</key>
            <summary>Doctrine fails to create correct table structure if model is named &quot;User&quot;</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="michenriksen">Michael Henriksen</reporter>
                        <labels>
                    </labels>
                <created>Wed, 16 Dec 2009 13:59:26 +0000</created>
                <updated>Fri, 8 Jan 2010 20:31:09 +0000</updated>
                                    <version>1.2.0-RC1</version>
                                                <component>Behaviors</component>
                <component>Query</component>
                <component>Relations</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="11201" author="michenriksen" created="Wed, 16 Dec 2009 14:04:39 +0000"  >&lt;p&gt;Forgot to mention, that it works perfectly when renaming model to something else than &quot;User&quot;&lt;/p&gt;</comment>
                    <comment id="11357" author="neographikal" created="Fri, 8 Jan 2010 20:31:09 +0000"  >&lt;p&gt;Have the same problem in 1.2.1 at PostgreSQL 8.4&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-329] Problem saving Self Referencing (Nest Relations)</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-329</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;There is a problem when you save Many to Many Self Referencing (Nest Relations).&lt;/p&gt;

&lt;p&gt;I used the same example that it&apos;s used on Doctrine 1.2 Self Referencing (Nest Relations) Documentation:&lt;/p&gt;

&lt;p&gt;My Schema:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;User:&lt;br/&gt;
  columns:&lt;br/&gt;
    name: &lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: { type}&lt;/span&gt; &lt;/div&gt;
&lt;p&gt;  relations:&lt;br/&gt;
    Parents:&lt;br/&gt;
      class: User&lt;br/&gt;
      local: child_id&lt;br/&gt;
      foreign: parent_id&lt;br/&gt;
      refClass: UserReference&lt;br/&gt;
      foreignAlias: Children&lt;/p&gt;

&lt;p&gt;UserReference:&lt;br/&gt;
  columns:&lt;br/&gt;
    parent_id:&lt;br/&gt;
      type: integer&lt;br/&gt;
      primary: true&lt;br/&gt;
    child_id:&lt;br/&gt;
      type: integer&lt;br/&gt;
      primary: true&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Fixtures:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;User:&lt;br/&gt;
  james:&lt;br/&gt;
    name: James&lt;br/&gt;
  alexander:&lt;br/&gt;
    name: Alexander&lt;br/&gt;
  david:&lt;br/&gt;
    name: David&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;The problem happens with the Children. The first time I assigned children and saved the User, there is no problem; but when I saved the User again (without any change on him) the values in the UserReference? table changes: the &quot;parent_id&quot; takes the value of the &quot;child_id&quot;.&lt;/p&gt;

&lt;p&gt;I test it with Sf 1.4 and with Sf 1.3 stable versions, and I&apos;ve got the same error.&lt;/p&gt;

&lt;p&gt;If it not clear to understand what I&apos;m saying, I put a &quot;very ilustrative&quot; image about the form and how change the values of the UserReference? table. Please see it, because it would be very usefull for understanding (explains better than my terrible English)&lt;/p&gt;

&lt;p&gt;Thanks for all your work! &lt;/p&gt;

&lt;p&gt;P. D. &lt;/p&gt;

&lt;p&gt;I forgot to to say that watching the stack trace I think that the problem is in:&lt;/p&gt;

&lt;p&gt;symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php&lt;/p&gt;

&lt;p&gt;In the line 429:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;public function saveAssociations(Doctrine_Record $record)&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;I would like to help more, but I couldn&apos;t figure out how this function works.&lt;/p&gt;</description>
                <environment>Mac OSX 10.5, Symfony 1.4 and MAMP</environment>
            <key id="10566">DC-329</key>
            <summary>Problem saving Self Referencing (Nest Relations)</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="jaimesuez">Jaime Suez</reporter>
                        <labels>
                    </labels>
                <created>Sat, 5 Dec 2009 17:48:37 +0000</created>
                <updated>Fri, 3 Jun 2011 13:14:55 +0000</updated>
                                    <version>1.2.0</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>14</votes>
                        <watches>14</watches>
                        <comments>
                    <comment id="11033" author="jaimesuez" created="Mon, 7 Dec 2009 00:38:52 +0000"  >&lt;p&gt;This picture explains the error that it&apos;s done when you do an insert and then you save it again.&lt;/p&gt;</comment>
                    <comment id="11048" author="jwage" created="Mon, 7 Dec 2009 17:59:04 +0000"  >&lt;p&gt;Can you provide a failing Doctrine test case? This may be a problem with Symfony and not Doctrine.&lt;/p&gt;</comment>
                    <comment id="11079" author="jaimesuez" created="Tue, 8 Dec 2009 12:55:47 +0000"  >&lt;p&gt;First I published this bug on Symfony, because I thought that was a problem with Symfony, but you set it as invalid because it&apos;s belong to Doctrine.&lt;/p&gt;

&lt;p&gt;This is the ticket on symfony: &lt;br/&gt;
&lt;a href=&quot;http://trac.symfony-project.org/ticket/7690&quot; class=&quot;external-link&quot;&gt;http://trac.symfony-project.org/ticket/7690&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I could do the Doctrine test case, but in one more mounth, because tomorrow I go out for vacations.&lt;br/&gt;
When I come back I&apos;ll do them.&lt;/p&gt;</comment>
                    <comment id="11244" author="psylosss" created="Sun, 20 Dec 2009 20:01:08 +0000"  >&lt;p&gt;Yes, I have got the same problem. During hours of debugging and exploring Doctrine&apos;s code, I found that problem localized in Hydrator component. I cannot digg deeper, so I ask you to fix it very much&lt;/p&gt;</comment>
                    <comment id="11296" author="p16" created="Sat, 26 Dec 2009 15:09:43 +0000"  >&lt;p&gt;Hi,&lt;br/&gt;
I had this problem in the 1.0 version of doctrine as well.&lt;br/&gt;
Using symfony, I upgraded to symfony 1.3 and doctrine 1.2 and I&apos;ve found the same problem.&lt;/p&gt;

&lt;p&gt;Attached to this comment you can find the files containing the schema I used (it is the same as that describe on this ticket but with a different class naming), and 2 unit tests. One using the symfony form  and one using directly the doctrine objects. They report the bug discussed on this ticket and show another bug saving objects that already have one ore more relations.&lt;/p&gt;

&lt;p&gt;As fixtures I used a fixtures.yml file containing: &lt;/p&gt;

&lt;p&gt;Issue:&lt;br/&gt;
&amp;lt;?php for ($i = 1; $i &amp;lt;= 30; $i++): ?&amp;gt;&lt;br/&gt;
  Issue_&amp;lt;?php echo $i; ?&amp;gt;:&lt;br/&gt;
    title: &quot;new issue &amp;lt;?php echo $i ?&amp;gt;&quot;&lt;br/&gt;
&amp;lt;?php endfor; ?&amp;gt;&lt;/p&gt;


&lt;p&gt;The following are the tests results:&lt;/p&gt;

&lt;p&gt;&amp;#8211; testEqualNestRelationsTest.php (using the forms) &amp;#8211; &lt;/p&gt;

&lt;p&gt;&amp;gt; First form for first issue: creation of the relation &quot;issue 1 -&amp;gt; issue 2&quot;&lt;br/&gt;
ok 1 - the edit form for issue 1 is valid&lt;br/&gt;
ok 2 - form1 saved&lt;br/&gt;
ok 3 - issue 1 is related with another issue&lt;br/&gt;
ok 4 - issue 1 is really related with issue 2&lt;/p&gt;

&lt;p&gt;&amp;gt; Second form for first issue: saving the relation between &quot;issue 1&quot; and &quot;issue 2&quot; from &quot;issue 2&quot;&apos;s form&lt;br/&gt;
ok 5 - the edit form for issue 2 is valid&lt;br/&gt;
ok 6 - form2 saved&lt;br/&gt;
not ok 7 - issue 2 is related with another issue  ******** this is the problem reported on this ticket ********&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Failed test (./test/unit/testEqualNestRelationsTest.php at line 57)&lt;/li&gt;
	&lt;li&gt;got: 0&lt;/li&gt;
	&lt;li&gt;expected: 1&lt;br/&gt;
not ok 8 - issue 2 is really related with issue 1&lt;/li&gt;
	&lt;li&gt;Failed test (./test/unit/testEqualNestRelationsTest.php at line 58)&lt;/li&gt;
	&lt;li&gt;got: NULL&lt;/li&gt;
	&lt;li&gt;expected: 1&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;ok 9 - issue 1 is related with another issue&lt;br/&gt;
not ok 10 - issue 1 is really related with issue 2  ******** this is the problem reported on this ticket ********&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Failed test (./test/unit/testEqualNestRelationsTest.php at line 63)&lt;/li&gt;
	&lt;li&gt;got: &apos;1&apos;&lt;/li&gt;
	&lt;li&gt;expected: 2&lt;br/&gt;
&amp;gt; Checking the relation table IssueReference ...&lt;br/&gt;
ok 11 - There is only one relation saved on IssueReference&lt;br/&gt;
ok 12 - 1 is the issue1 field of the relation&lt;br/&gt;
not ok 13 - 2 is the issue2 field of the relation ******** this is the problem reported on this ticket ********&lt;/li&gt;
	&lt;li&gt;Failed test (./test/unit/testEqualNestRelationsTest.php at line 71)&lt;/li&gt;
	&lt;li&gt;got: &apos;1&apos;&lt;/li&gt;
	&lt;li&gt;expected: &apos;2&apos;&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&amp;gt; multi selection proof&lt;br/&gt;
ok 14 - the edit form for issue 1 is valid&lt;br/&gt;
ok 15 - form1 saved&lt;br/&gt;
ok 16 - the edit form for issue 2 is valid&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;
	&lt;ul&gt;
		&lt;li&gt;
		&lt;ul&gt;
			&lt;li&gt;
			&lt;ul&gt;
				&lt;li&gt;
				&lt;ul&gt;
					&lt;li&gt;
					&lt;ul&gt;
						&lt;li&gt;
						&lt;ul&gt;
							&lt;li&gt;
							&lt;ul&gt;
								&lt;li&gt;this is the other bug I&apos;ve found ********&lt;br/&gt;
not ok 17 - form2 exception catched : SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;23000&amp;#93;&lt;/span&gt;: Integrity constraint violation: 1062 Duplicate entry &apos;1-1&apos; for key 1&lt;/li&gt;
							&lt;/ul&gt;
							&lt;/li&gt;
						&lt;/ul&gt;
						&lt;/li&gt;
					&lt;/ul&gt;
					&lt;/li&gt;
				&lt;/ul&gt;
				&lt;/li&gt;
			&lt;/ul&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
	&lt;li&gt;Failed test (./test/unit/testEqualNestRelationsTest.php at line 114)&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&amp;#8211; testNestedEqualRelationWithObjectsTest.php (test using the &quot;doctrine&quot; objects ) &amp;#8211;&lt;/p&gt;

&lt;p&gt;&amp;gt; Saving relation directly from the objects and not using the forms...&lt;br/&gt;
ok 1 - issue1 saved&lt;br/&gt;
&amp;gt; checking issue1 relations&lt;br/&gt;
ok 2 - issue 1 is related with another issue&lt;br/&gt;
ok 3 - issue 1 is really related with issue 2&lt;/p&gt;

&lt;p&gt;&amp;gt; checking &quot;reverse&quot; relation on issue2&lt;br/&gt;
ok 4 - issue 2 is related with another issue&lt;br/&gt;
ok 5 - issue 2 is really related with issue 1&lt;/p&gt;

&lt;p&gt;&amp;gt; adding a relation issue2-&amp;gt;issue1 directly&lt;br/&gt;
ok 6 - issue2 saved&lt;/p&gt;

&lt;p&gt;&amp;gt; checking issue2 relations&lt;br/&gt;
not ok 7 - issue 2 is related with another issue  ******** this is the problem reported on this ticket ********&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Failed test (./test/unit/testNestedEqualRelationWithObjectsTest.php at line 56)&lt;/li&gt;
	&lt;li&gt;got: 0&lt;/li&gt;
	&lt;li&gt;expected: 1&lt;br/&gt;
not ok 8 - issue 2 is really related with issue 1&lt;/li&gt;
	&lt;li&gt;Failed test (./test/unit/testNestedEqualRelationWithObjectsTest.php at line 57)&lt;/li&gt;
	&lt;li&gt;got: NULL&lt;/li&gt;
	&lt;li&gt;expected: 1&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&amp;gt; checking issue1 relations&lt;br/&gt;
ok 9 - issue 1 is related with another issue&lt;br/&gt;
not ok 10 - issue 1 is really related with issue 2  ******** this is the problem reported on this ticket ********&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Failed test (./test/unit/testNestedEqualRelationWithObjectsTest.php at line 63)&lt;/li&gt;
	&lt;li&gt;got: &apos;1&apos;&lt;/li&gt;
	&lt;li&gt;expected: 2&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&amp;gt; Checking the relation table IssueReference ...&lt;br/&gt;
ok 11 - There is only one relation saved on IssueReference&lt;br/&gt;
ok 12 - 1 is the issue1 field of the relation&lt;br/&gt;
not ok 13 - 2 is the issue2 field of the relation&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Failed test (./test/unit/testNestedEqualRelationWithObjectsTest.php at line 71)&lt;/li&gt;
	&lt;li&gt;got: &apos;1&apos;&lt;/li&gt;
	&lt;li&gt;expected: &apos;2&apos;&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&amp;gt; object multi adding relation proof&lt;br/&gt;
ok 14 - issue1 saved&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;
	&lt;ul&gt;
		&lt;li&gt;
		&lt;ul&gt;
			&lt;li&gt;
			&lt;ul&gt;
				&lt;li&gt;
				&lt;ul&gt;
					&lt;li&gt;
					&lt;ul&gt;
						&lt;li&gt;
						&lt;ul&gt;
							&lt;li&gt;
							&lt;ul&gt;
								&lt;li&gt;this is the other bug I&apos;ve found ********&lt;br/&gt;
not ok 15 - issue2 exception catched : SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;23000&amp;#93;&lt;/span&gt;: Integrity constraint violation: 1062 Duplicate entry &apos;1-1&apos; for key 1&lt;/li&gt;
							&lt;/ul&gt;
							&lt;/li&gt;
						&lt;/ul&gt;
						&lt;/li&gt;
					&lt;/ul&gt;
					&lt;/li&gt;
				&lt;/ul&gt;
				&lt;/li&gt;
			&lt;/ul&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
	&lt;li&gt;Failed test (./test/unit/testNestedEqualRelationWithObjectsTest.php at line 112)&lt;/li&gt;
&lt;/ol&gt;


</comment>
                    <comment id="11370" author="jaimesuez" created="Wed, 13 Jan 2010 15:27:21 +0000"  >&lt;p&gt;With the test provided by Filippo De Santis is any other thing needed??&lt;/p&gt;

&lt;p&gt;I still on vacations untill 3 of febrary, so then I could do any other thing needed.&lt;/p&gt;
</comment>
                    <comment id="11571" author="jaimesuez" created="Mon, 1 Feb 2010 15:54:37 +0000"  >&lt;p&gt;The necessary test have to be how are illustrated in this link???&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/documentation/manual/1_2/en/unit-testing&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/documentation/manual/1_2/en/unit-testing&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="11648" author="bgm" created="Tue, 9 Feb 2010 22:35:23 +0000"  >&lt;p&gt;What has happen with this bug?? I also have the same problem...&lt;/p&gt;</comment>
                    <comment id="11968" author="jwage" created="Tue, 2 Mar 2010 12:43:43 +0000"  >&lt;p&gt;Hi, yes. We still need a unit test case like described here: &lt;a href=&quot;http://www.doctrine-project.org/documentation/manual/1_2/en/unit-testing&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/documentation/manual/1_2/en/unit-testing&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So we can run it with all the other tests and reproduce the issue in Doctrine by itself. Not in Symfony.&lt;/p&gt;

&lt;p&gt;Thanks, Jon&lt;/p&gt;</comment>
                    <comment id="11988" author="psylosss" created="Tue, 2 Mar 2010 15:13:30 +0000"  >&lt;p&gt;Jon, here is the test for this bug: &lt;a href=&quot;http://gist.github.com/319856&quot; class=&quot;external-link&quot;&gt;http://gist.github.com/319856&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please, fix it.. my work has been stopped cause of it&lt;/p&gt;</comment>
                    <comment id="12203" author="jaimesuez" created="Mon, 15 Mar 2010 13:12:55 +0000"  >&lt;p&gt;Yes... please fix it... I&apos;m also stuck in my work since a lot of time that the bug it&apos;s open.&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;</comment>
                    <comment id="12212" author="lilawolf" created="Mon, 15 Mar 2010 14:24:37 +0000"  >&lt;p&gt;I&apos;m affected with this bug as well, fortunately, I found a way to get over it, it&apos;s ugly and innefficient, but at least my work isn&apos;t stopped due to this bug. I&apos;ll try to explain what I did commenting here later. Anyway, I really need this bug fixed too before I can start betatesting my app.&lt;br/&gt;
Thanks!&lt;/p&gt;

&lt;p&gt;P.D: I&apos;m using Doctrine 1.2.1.&lt;/p&gt;</comment>
                    <comment id="12215" author="jwage" created="Mon, 15 Mar 2010 14:35:09 +0000"  >&lt;p&gt;I am trying to understand the issue but it just doesn&apos;t make much sense to me yet. The test case is wrong because you are dealing with instances of objects that have previously loaded references, then you try and re-fetch the same object instance. If you do $user1-&amp;gt;free(true); then re-fetch the object the test passes as expected. So, I don&apos;t really have a proper failing test case still that actually exposes the problem. I&apos;ll keep playing around see if I can understand. let me know if anyone else has more information or a patch to test.&lt;/p&gt;

&lt;p&gt;Thanks, Jon&lt;/p&gt;</comment>
                    <comment id="12296" author="p16" created="Tue, 16 Mar 2010 17:22:33 +0000"  >&lt;p&gt;Hi Jonathan,&lt;br/&gt;
This is the &quot;translated&quot; version of my unit test for symfony in &quot;doctrine unit test&quot;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/ideato/phpcollab3/blob/phpcollabsf13/test/doctrine_unit_test/DC329TestCase.php&quot; class=&quot;external-link&quot;&gt;http://github.com/ideato/phpcollab3/blob/phpcollabsf13/test/doctrine_unit_test/DC329TestCase.php&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first test is to show the error &quot;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;23000&amp;#93;&lt;/span&gt;: Integrity constraint violation: 19 columns issue1, issue2 are not unique&quot;.&lt;br/&gt;
The second one is to show the fact that the relation are saved with wrong data.&lt;/p&gt;

&lt;p&gt;Sorry for the late translation.&lt;/p&gt;

&lt;p&gt;Filippo &lt;/p&gt;</comment>
                    <comment id="12299" author="hckurniawan" created="Tue, 16 Mar 2010 21:55:53 +0000"  >&lt;p&gt;Hi Jonathan,&lt;/p&gt;

&lt;p&gt;It seems that the problem is caused by Doctrine_Collection::add() method line 456 (I could be totally wrong).&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (isset($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;referenceField)) {
    $value = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;reference-&amp;gt;get($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;relation-&amp;gt;getLocalFieldName());
    &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($value !== &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;) {
        $record-&amp;gt;set($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;referenceField, $value, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;);
    } &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt; {
        $record-&amp;gt;set($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;referenceField, $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;reference, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;);
    }
...
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;What is trying to do is to set the reference field value to the reference value that it&apos;s linked to.&lt;/p&gt;

&lt;p&gt;This only happens when you try to fetch record from the &quot;children&quot;.&lt;/p&gt;

&lt;p&gt;Consider the following:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;Employees:
  tableName: employees
  columns:
    id:
      type: integer(4)
      primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      autoincrement: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    name:
      type: string(100)
  relations:
    managing:
      class: Employees
      type: many
      local: manager_id
      foreign: employee_id
      foreignAlias: managedBy
      refClass: EmployeeManager

EmployeeManager:
...
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Code:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-comment&quot;&gt;// ----- The following will not give you any issues
&lt;/span&gt;  $manager = Doctrine::getTable(&apos;Issue&apos;)-&amp;gt;findOneBy(&apos;id&apos;, &apos;1&apos;); &lt;span class=&quot;code-comment&quot;&gt;// This is a manager
&lt;/span&gt;  foreach ($manager-&amp;gt;managing as $employee) {
    ....
  }

  &lt;span class=&quot;code-comment&quot;&gt;// This will not save anything
&lt;/span&gt;  $manager-&amp;gt;save();
&lt;span class=&quot;code-comment&quot;&gt;// -----
&lt;/span&gt;
&lt;span class=&quot;code-comment&quot;&gt;// ----- The following will
&lt;/span&gt;  $employee = Doctrine::getTable(&apos;Issue&apos;)-&amp;gt;findOneBy(&apos;id&apos;, &apos;2&apos;); &lt;span class=&quot;code-comment&quot;&gt;// This is an employee
&lt;/span&gt;  foreach ($employee-&amp;gt;managedBy as $manager) {
    ...
  }

  &lt;span class=&quot;code-comment&quot;&gt;// This will save the wrong data to the &lt;span class=&quot;code-quote&quot;&gt;&quot;EmployeeManager&quot;&lt;/span&gt; table
&lt;/span&gt;  &lt;span class=&quot;code-comment&quot;&gt;// because the code from Doctrine_Collection is overwriting &lt;span class=&quot;code-quote&quot;&gt;&quot;EmployeeManager&quot;&lt;/span&gt; records
&lt;/span&gt;  &lt;span class=&quot;code-comment&quot;&gt;// When they were being added to the collection by the Hydrator.
&lt;/span&gt;  $employee-&amp;gt;save();
&lt;span class=&quot;code-comment&quot;&gt;// -----&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;Debug backtrace when this happens:&lt;/p&gt;
&lt;div class=&quot;panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;panelContent&quot;&gt;
&lt;p&gt;string(100) &quot;File: /Data/app/onlinevw-drupalvividwireless/libs/external-doctrine1/Doctrine/Record.php @ line 1432&quot;&lt;br/&gt;
string(103) &quot;File: /Data/app/onlinevw-drupalvividwireless/libs/external-doctrine1/Doctrine/Collection.php @ line 461&quot;&lt;br/&gt;
string(99) &quot;File: /Data/app/onlinevw-drupalvividwireless/libs/external-doctrine1/Doctrine/Access.php @ line 131&quot;&lt;br/&gt;
string(107) &quot;File: /Data/app/onlinevw-drupalvividwireless/libs/external-doctrine1/Doctrine/Hydrator/Graph.php @ line 229&quot;&lt;br/&gt;
string(101) &quot;File: /Data/app/onlinevw-drupalvividwireless/libs/external-doctrine1/Doctrine/Hydrator.php @ line 137&quot;&lt;br/&gt;
string(108) &quot;File: /Data/app/onlinevw-drupalvividwireless/libs/external-doctrine1/Doctrine/Query/Abstract.php @ line 1036&quot;&lt;br/&gt;
string(105) &quot;File: /Data/app/onlinevw-drupalvividwireless/libs/external-doctrine1/Doctrine/Relation/Nest.php @ line 84&quot;&lt;br/&gt;
string(100) &quot;File: /Data/app/onlinevw-drupalvividwireless/libs/external-doctrine1/Doctrine/Record.php @ line 1362&quot;&lt;br/&gt;
string(100) &quot;File: /Data/app/onlinevw-drupalvividwireless/libs/external-doctrine1/Doctrine/Record.php @ line 1333&quot;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="12372" author="loops" created="Fri, 19 Mar 2010 12:33:35 +0000"  >&lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;For people who are looking for a workaround, I&apos;ve found one that work for me.&lt;/p&gt;

&lt;p&gt;Get the doctrine extension h2aEqualable (h2aEqualable.zip), register it as a doctrine extension (see &lt;a href=&quot;http://www.doctrine-project.org/documentation/manual/1_2/0_11/extensions&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/documentation/manual/1_2/0_11/extensions&lt;/a&gt;) and make your refClass of every equal nest relation acting as h2aEqualable.&lt;/p&gt;

&lt;p&gt;In your PHP script :&lt;br/&gt;
{{&lt;br/&gt;
Doctrine::setExtensionsPath( &apos;path/to/unzip/place&apos; );&lt;br/&gt;
Doctrine_Manager::getInstance()-&amp;gt;registerExtension( &apos;h2aEqualable&apos; );&lt;br/&gt;
}}&lt;/p&gt;

&lt;p&gt;In your YAML schema :&lt;br/&gt;
{{&lt;br/&gt;
MyEqualNestRelationRefClassModel:&lt;br/&gt;
  actAs:&lt;br/&gt;
    h2aEqualable:&lt;br/&gt;
      fields: &lt;span class=&quot;error&quot;&gt;&amp;#91;id_1,id_2&amp;#93;&lt;/span&gt;&lt;br/&gt;
}}&lt;/p&gt;

&lt;p&gt;As I&apos;ve said before, it works for me, so let me know if it solve your issues too...&lt;/p&gt;</comment>
                    <comment id="13365" author="pgueguin" created="Fri, 18 Jun 2010 12:57:55 +0000"  >&lt;p&gt;I have the very same issue with non equal nest relations.&lt;br/&gt;
It is stopping my project&lt;/p&gt;

&lt;p&gt;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;23000&amp;#93;&lt;/span&gt;: Integrity constraint violation: 1062 Duplicate entry &apos;87-87&apos; for key &apos;PRIMARY&apos;&lt;/p&gt;

&lt;p&gt;execute : UPDATE cop_job_stream_successor SET job_stream_destination_id = ?, updated_at = ? WHERE job_stream_source_id = ? AND job_stream_destination_id = ? - (87, 2010-06-18 18:55:32, 87, 94) &lt;/p&gt;

&lt;p&gt;CopJobStream:&lt;br/&gt;
  columns:&lt;br/&gt;
    name:&lt;br/&gt;
      type: string(255)&lt;br/&gt;
      notnull: false&lt;br/&gt;
....&lt;br/&gt;
  relations:&lt;br/&gt;
   SuccessorJobStreams:&lt;br/&gt;
     class: CopJobStream&lt;br/&gt;
     local: job_stream_source_id&lt;br/&gt;
     foreign: job_stream_destination_id    &lt;br/&gt;
     refClass: CopJobStreamSuccessor&lt;br/&gt;
     foreignAlias: PredecessorJobStreams&lt;br/&gt;
     onDelete: CASCADE &lt;br/&gt;
     onUpdate: CASCADE &lt;/p&gt;

&lt;p&gt;CopJobStreamSuccessor:&lt;br/&gt;
  columns:&lt;br/&gt;
   job_stream_source_id:&lt;br/&gt;
     type: integer&lt;br/&gt;
     primary: true&lt;br/&gt;
   job_stream_destination_id:&lt;br/&gt;
     type: integer&lt;br/&gt;
     primary: true&lt;br/&gt;
  relations:&lt;br/&gt;
    CopJobStream:&lt;br/&gt;
      local: job_stream_source_id&lt;br/&gt;
      foreignAlias: CopJobStreamSuccessors&lt;br/&gt;
      onDelete: CASCADE&lt;br/&gt;
      onUpdate: CASCADE    &lt;/p&gt;</comment>
                    <comment id="13367" author="pgueguin" created="Fri, 18 Jun 2010 14:20:28 +0000"  >&lt;p&gt;It works anyway with above   h2aEqualable extension&lt;/p&gt;</comment>
                    <comment id="15186" author="bigbadbassman" created="Wed, 26 Jan 2011 02:39:36 +0000"  >&lt;p&gt;after stumbling into the same pit as everyone, i created a fresh report as &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-958&quot; title=&quot;updating Models with Intra-Table Relations cascades strangely&quot;&gt;DC-958&lt;/a&gt;. Later I found out that it has been reported before, so please mark &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-958&quot; title=&quot;updating Models with Intra-Table Relations cascades strangely&quot;&gt;DC-958&lt;/a&gt; as duplicate of this. (or at least related, as I was using a Non-Equal Nested Set) also &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-952&quot; title=&quot;Non-Equal Nest Relations Not Working - from &amp;quot;Children&amp;quot; side&quot;&gt;DC-952&lt;/a&gt; refers to the same problem, but also with Non-Equal nestet sets.&lt;/p&gt;

&lt;p&gt;My Case:  Non-Equal-Nested-Set. Problems occur on saving Objects for 2nd or more time. Doctrine deletes all Child-Relations of the Object to be saved and updates Relations of the Childs to other Objects (other parents of the children objects) with references to the child itself!&lt;/p&gt;

&lt;p&gt;the proposed h2aEqualable extension does prevent the wrong update statements but not the initial delete of the child-relations.&lt;/p&gt;

&lt;p&gt;What exactly is missing on this bug to be fixed? It is now a year old, and clearly preventing people from using Self-Referencing relations with doctrine.&lt;/p&gt;

&lt;p&gt;How can we help? More sample data, schema definitions, test cases?&lt;/p&gt;</comment>
                    <comment id="15309" author="flevour" created="Tue, 15 Feb 2011 06:41:46 +0000"  >&lt;p&gt;Here is a better and simpler test case for the equal relation: &lt;a href=&quot;https://gist.github.com/827414&quot; class=&quot;external-link&quot;&gt;https://gist.github.com/827414&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is clearly a memory problem here. I&apos;ll leave it up to Jonathan to decide whether it&apos;s a scenario which can be avoided in Doctrine itself or must be handled by Symfony (&lt;a href=&quot;http://trac.symfony-project.org/ticket/9398&quot; class=&quot;external-link&quot;&gt;http://trac.symfony-project.org/ticket/9398&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;In the Symfony context calls to refresh() might not be an option when modifying an object (aka saving a form).&lt;/p&gt;</comment>
                    <comment id="15333" author="yitznewton" created="Thu, 17 Feb 2011 12:06:55 +0000"  >&lt;p&gt;h2aEqualable seems to work for me.&lt;/p&gt;</comment>
                    <comment id="15898" author="pavel.campr" created="Thu, 2 Jun 2011 07:48:44 +0000"  >&lt;p&gt;h2aEqualable works only partly for me (same as Daniel Reiche wrote).&lt;/p&gt;

&lt;p&gt;I tried to identify the problem. &lt;/p&gt;

&lt;p&gt;My usecase was: &lt;br/&gt;
1) I have an Article record in $article&lt;br/&gt;
2) I called $article-&amp;gt;RelatedArticles-&amp;gt;getPrimaryKeys() , where RelatedArticles is a name of my self reference&lt;br/&gt;
3) $article-&amp;gt;save();&lt;/p&gt;

&lt;p&gt;The problem originates from step 2), during hydratation process for related articles, which are added to a collection of related articles, in Collection-&amp;gt;add() method (line 465) here:&lt;/p&gt;

&lt;p&gt;            if ($value !== null) &lt;/p&gt;
{
                $record-&amp;gt;set($this-&amp;gt;referenceField, $value, false);
            }
&lt;p&gt; else {&lt;/p&gt;

&lt;p&gt;but, $this-&amp;gt;referenceField contains wrong name of reference field. Self referenced model (Article) has two relations to the same class (one from &quot;owning&quot; side, second from &quot;referencing&quot; side). $this-&amp;gt;referenceField in the collection is somewhere filled with the wrong relation name (not the&quot;referencing&quot; one, but the &quot;owning&quot; one). &lt;/p&gt;

&lt;p&gt;When I save the $article, all referenced records are saved too and this is the problem, why the Doctrine tries to save corrupted data:&lt;/p&gt;

&lt;p&gt;In my example, I have this data:&lt;/p&gt;

&lt;p&gt;in Doctrine_Collection-&amp;gt;add on line 457: $record) is a RelatedArticle (&lt;br/&gt;
    article1 = string(1) &quot;4&quot;&lt;br/&gt;
    article2 = string(1) &quot;9&quot;&lt;br/&gt;
)&lt;br/&gt;
in Doctrine_Collection-&amp;gt;add on line 458: $this-&amp;gt;referenceField) = string(19) &quot;article1&quot;&lt;br/&gt;
in Doctrine_Collection-&amp;gt;add on line 459: $value) = string(1) &quot;9&quot;   &lt;/p&gt;

&lt;p&gt;BUT expected data is:&lt;/p&gt;

&lt;p&gt;in Doctrine_Collection-&amp;gt;add on line 458: $this-&amp;gt;referenceField) = string(19) &quot;article2&quot;&lt;/p&gt;


&lt;p&gt;This wrong behavior modified my RelatedArticle into this: RelatedArticle (&lt;br/&gt;
    article1 = string(1) &quot;9&quot;&lt;br/&gt;
    article2 = string(1) &quot;9&quot;&lt;br/&gt;
)&lt;/p&gt;


&lt;p&gt;I have no idea how to fix it, but maybe someone can, I hope &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;

&lt;p&gt;(&lt;br/&gt;
my schema is:&lt;/p&gt;

&lt;p&gt;Article&lt;br/&gt;
  relations:&lt;br/&gt;
    RelatedArticles:&lt;br/&gt;
      class: Article&lt;br/&gt;
      local: article1&lt;br/&gt;
      foreign: article2&lt;br/&gt;
      refClass: RelatedArticle&lt;br/&gt;
)&lt;/p&gt;

&lt;p&gt;Maybe, when &quot;refClassRelationAlias&quot; option was invented to specifically point to a relation, instead of using &quot;refClass&quot;, which can be used more times for one record and thus is not unambiguous, something for self referenced relations should be added as well. My &quot;refClass: RelatedArticle&quot; creates (probably) a relation from the foreign side too and Article contains two relations, which uses same refClass. Doctrine then doesn&apos;t know, which one should be used. &lt;/p&gt;
</comment>
                    <comment id="15901" author="pavel.campr" created="Fri, 3 Jun 2011 13:14:55 +0000"  >&lt;p&gt;&lt;b&gt;Non-equal&lt;/b&gt; nest relations work properly, when &lt;b&gt;refClassRelationAlias&lt;/b&gt; undocumented option is used, e.g.&lt;/p&gt;


&lt;p&gt;Article:&lt;br/&gt;
  ...&lt;br/&gt;
  relations:&lt;br/&gt;
    RelatedArticles:&lt;br/&gt;
      class: Article&lt;br/&gt;
      local: article1&lt;br/&gt;
      foreign: article2&lt;br/&gt;
      refClass: RelatedArticle&lt;br/&gt;
      refClassRelationAlias: RelatedArticleAlias&lt;/p&gt;

&lt;p&gt;Anything can be used as a value for refClassRelationAlias.&lt;/p&gt;

&lt;p&gt;Unfortunately, &lt;b&gt;this doesn&apos;t fix equal nest relations&lt;/b&gt;.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10505" name="h2aEqualable.zip" size="3041" author="loops" created="Fri, 19 Mar 2010 12:33:52 +0000" />
                    <attachment id="10216" name="saving process.png" size="64255" author="jaimesuez" created="Mon, 7 Dec 2009 00:38:52 +0000" />
                    <attachment id="10260" name="schema.yml" size="443" author="p16" created="Sat, 26 Dec 2009 15:09:43 +0000" />
                    <attachment id="10261" name="testEqualNestRelationsTest.php" size="3598" author="p16" created="Sat, 26 Dec 2009 15:09:43 +0000" />
                    <attachment id="10262" name="testNestedEqualRelationWithObjectsTest.php" size="3391" author="p16" created="Sat, 26 Dec 2009 15:09:43 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-290] Relations need alias</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-290</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;While implementing a Record_Template and manipulating a query by using the preDqlSelect Event, i got massive problems if the query was generated by a refresh() or refreshRelated() call. I found out that the issue appears because the query has no alias for the table then. This makes it hard to add forther (sub-)selects to the query via preDqlSelect, e.g.&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$params = $event-&amp;gt;getParams();
		$alias = $params[&apos;alias&apos;];

                &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;(!$query-&amp;gt;isSubquery() &amp;amp;&amp;amp; $alias == $queryClone-&amp;gt;getRootAlias()) {	
				
				
				$countQuery = &apos;(SELECT COUNT(&apos;.$alias.&apos;_tcount.uid) FROM &apos;.$modelName.&apos; &apos;.$alias.&apos;_tcount WHERE &apos;.$alias.&apos;.&apos;.$groupId.&apos;=&apos;.$alias.&apos;_tcount.&apos;.$groupId.&apos;) AS &apos;.$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_options[&apos;terminationCount&apos;];
				
				$query-&amp;gt;addSelect($countQuery);
			}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;



&lt;p&gt;The issue is solved by adding an alias in the foreignKey and localKey relation types&apos; fetchRelatedFor methods (at least that&apos;s sufficient for my issue, maybe there is a need to add similar lines to the other relation types).&lt;/p&gt;



&lt;p&gt;Doctrine_Relation_ForeignKey (from line 60):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$alias = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getTable()-&amp;gt;getComponentName().&apos;_rel&apos;;
            	
                $dql  = &apos;FROM &apos; . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getTable()-&amp;gt;getComponentName()
                      .&apos; &apos;.$alias. &apos; WHERE &apos; . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getCondition($alias) . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getOrderBy(&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;



&lt;p&gt;Doctrine_Relation_LocalKey (from line 58):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$alias = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getTable()-&amp;gt;getComponentName().&apos;_rel&apos;;
        	
            $dql  = &apos;FROM &apos; . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getTable()-&amp;gt;getComponentName()
                 .&apos; &apos;.$alias. &apos; WHERE &apos; . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getCondition($alias) . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getOrderBy(&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
            <key id="10506">DC-290</key>
            <summary>Relations need alias</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="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/reopened.png">Reopened</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="jensen83">Christian Jaentsch</reporter>
                        <labels>
                    </labels>
                <created>Wed, 25 Nov 2009 13:24:48 +0000</created>
                <updated>Wed, 9 Jun 2010 16:08:24 +0000</updated>
                                    <version>1.2.0-RC1</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="10921" author="jwage" created="Mon, 30 Nov 2009 17:45:00 +0000"  >&lt;p&gt;If no alias is explicitly defined, the alias is automatically set to the model name. So in your code change you changed it from &quot;ModelName&quot; to &quot;ModelName_rel&quot;. If you had the following:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;SELECT * FROM User
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The alias would be &quot;User&quot; and it is the same as if you did:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;SELECT * FROM User User
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="10938" author="jensen83" created="Tue, 1 Dec 2009 10:37:50 +0000"  >&lt;p&gt;unfortunately this does not solve my problem... i narrowed it down to be a problem with addPendingJoinCondition in such a case.&lt;/p&gt;

&lt;p&gt;here is a short scenario of what i want to do...&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$modelName = &apos;Exhibition&apos;;
$alias = &lt;span class=&quot;code-quote&quot;&gt;&quot;exhibitionalias&quot;&lt;/span&gt;;
$subAlias = &apos;exhibitionsub&apos;;
		
$query = Doctrine_Query::create()
-&amp;gt;from($modelName.&apos; &apos;.$alias);
		
$subQuery .= &apos;SELECT &apos;.$subAlias.&apos;.id FROM &apos;.$modelName.&apos; &apos;.$subAlias.&apos; WHERE &apos;.$subAlias.&apos;.id = &apos;.$alias.&apos;.id&apos;;
$query-&amp;gt;addPendingJoinCondition($alias, $alias.&apos;.id IN (&apos;.$subQuery.&apos;)&apos;);
		
$query-&amp;gt;execute();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;this works so far as the alias is different from the model name... but if i change&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$alias = &lt;span class=&quot;code-quote&quot;&gt;&quot;Exhibition&quot;&lt;/span&gt;;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;i get the exception&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;exception &apos;Doctrine_Exception&apos; with message &apos;Couldn&apos;t find class exhibitionsub&apos; in /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Table.php:299
Stack trace:
#0 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Table.php(249): Doctrine_Table-&amp;gt;initDefinition()
#1 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Connection.php(1126): Doctrine_Table-&amp;gt;__construct(&apos;exhibitionsub&apos;, &lt;span class=&quot;code-object&quot;&gt;Object&lt;/span&gt;(Doctrine_Connection_Mysql), &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;)
#2 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query.php(1924): Doctrine_Connection-&amp;gt;getTable(&apos;exhibitionsub&apos;)
#3 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query.php(1722): Doctrine_Query-&amp;gt;loadRoot(&apos;exhibitionsub&apos;, &apos;exhibitionsub&apos;)
#4 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query/Where.php(76): Doctrine_Query-&amp;gt;load(&apos;exhibitionsub&apos;, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;)
#5 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query/Condition.php(92): Doctrine_Query_Where-&amp;gt;load(&apos;exhibitionsub.i...&apos;)
#6 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query/Abstract.php(2077): Doctrine_Query_Condition-&amp;gt;parse(&apos;exhibitionsub.i...&apos;)
#7 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query.php(1156): Doctrine_Query_Abstract-&amp;gt;_processDqlQueryPart(&apos;where&apos;, Array)
#8 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query.php(1122): Doctrine_Query-&amp;gt;buildSqlQuery(&lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;)
#9 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query/Abstract.php(1137): Doctrine_Query-&amp;gt;getSqlQuery(Array, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;)
#10 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query/Abstract.php(1106): Doctrine_Query_Abstract-&amp;gt;_getDqlCallbackComponents(Array)
#11 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query.php(1143): Doctrine_Query_Abstract-&amp;gt;_preQuery()
#12 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query.php(1122): Doctrine_Query-&amp;gt;buildSqlQuery(&lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;)
#13 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query/JoinCondition.php(87): Doctrine_Query-&amp;gt;getSqlQuery()
#14 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query/Condition.php(92): Doctrine_Query_JoinCondition-&amp;gt;load(&apos;Exhibition.id I...&apos;)
#15 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query.php(1089): Doctrine_Query_Condition-&amp;gt;parse(&apos;Exhibition.id I...&apos;)
#16 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query.php(1013): Doctrine_Query-&amp;gt;_processPendingJoinConditions(&apos;Exhibition&apos;)
#17 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query.php(1228): Doctrine_Query-&amp;gt;_buildSqlFromPart()
#18 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query.php(1122): Doctrine_Query-&amp;gt;buildSqlQuery(&lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;)
#19 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query/Abstract.php(1137): Doctrine_Query-&amp;gt;getSqlQuery(Array, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;)
#20 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query/Abstract.php(1106): Doctrine_Query_Abstract-&amp;gt;_getDqlCallbackComponents(Array)
#21 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/core/lib/Doctrine/Doctrine/Query/Abstract.php(1001): Doctrine_Query_Abstract-&amp;gt;_preQuery(Array)
#22 /&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt;/www/erh_eeecore/app/modules/&lt;span class=&quot;code-keyword&quot;&gt;default&lt;/span&gt;/controllers/ExhibitionsController.php(75): Doctrine_Query_Abstract-&amp;gt;execute()
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="11057" author="jwage" created="Mon, 7 Dec 2009 19:50:11 +0000"  >&lt;p&gt;Hmm. Christian, your issue doesn&apos;t seem at all related to the original issue. It seems like an entirely different problem, no?&lt;/p&gt;</comment>
                    <comment id="11081" author="jensen83" created="Tue, 8 Dec 2009 13:38:21 +0000"  >&lt;p&gt;Well, I don&apos;t know where the reason for the problem is exactly... I just solved my problem by adding an alias to the foreignKey and localKey relations. The actual problem seems to be located in how the query is processed if the alias is equal to the name of the &quot;from&quot;-model. this causes problems while adding pending join conditions.&lt;/p&gt;</comment>
                    <comment id="11098" author="jwage" created="Tue, 8 Dec 2009 18:04:42 +0000"  >&lt;p&gt;Ok, well what you described is totally un-related to this issue. If you have found a bug you can open another ticket with detailed information and a failing test case. Thanks, Jon&lt;/p&gt;</comment>
                    <comment id="13197" author="jwage" created="Tue, 8 Jun 2010 15:07:07 +0000"  >&lt;p&gt;Can you show a patch with your changes?&lt;/p&gt;</comment>
                    <comment id="13260" author="jensen83" created="Wed, 9 Jun 2010 16:08:24 +0000"  >&lt;p&gt;My patch is as shown in the description of this issue:&lt;/p&gt;

&lt;p&gt;Doctrine_Relation_ForeignKey (from line 60):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$alias = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getTable()-&amp;gt;getComponentName().&apos;_rel&apos;;
            	
                $dql  = &apos;FROM &apos; . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getTable()-&amp;gt;getComponentName()
                      .&apos; &apos;.$alias. &apos; WHERE &apos; . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getCondition($alias) . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getOrderBy(&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;



&lt;p&gt;Doctrine_Relation_LocalKey (from line 58):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$alias = $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getTable()-&amp;gt;getComponentName().&apos;_rel&apos;;
        	
            $dql  = &apos;FROM &apos; . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getTable()-&amp;gt;getComponentName()
                 .&apos; &apos;.$alias. &apos; WHERE &apos; . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getCondition($alias) . $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getOrderBy(&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-684] After adding a Reference, the ForeignKeys in the DB are not updatet</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-684</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;After query a record from the DB, where a foreign key is null, and changing only the reference belonging to this foreign key, and only these reference no other value of the record, a save of the record doesn&apos;t lead to a change in the foreign key field.&lt;/p&gt;

&lt;p&gt;For example: I&apos;ll save a user record with some data of a regestration and give him the possibillity to add a city where he cames from later in his account settings, if no other user attribute is changed, the state of the user record is still CLEAN. The result is that I can access the user-&amp;gt;City property correctly only as long as no refresh from the db is done. So the changing of the foreign key belonging to the city isn&apos;t persistent in the DB.&lt;/p&gt;

&lt;p&gt;Example Code:&lt;br/&gt;
		$user = new Model_User();&lt;br/&gt;
		$user-&amp;gt;firstName = md5(rand());&lt;br/&gt;
		$user-&amp;gt;save();&lt;/p&gt;

&lt;p&gt;		$id = $user-&amp;gt;id;&lt;br/&gt;
		unset($user);&lt;br/&gt;
		assert(! $user);&lt;/p&gt;

&lt;p&gt;		$user = Model_UserTable::getInstance()-&amp;gt;find($id);&lt;br/&gt;
		assert(!$user-&amp;gt;relatedExists(&apos;City&apos;));		&lt;/p&gt;

&lt;p&gt;		$user-&amp;gt;City-&amp;gt;name = &apos;Mainz&apos;;&lt;br/&gt;
		$user-&amp;gt;save();&lt;br/&gt;
		unset($user);&lt;/p&gt;

&lt;p&gt;		$user = Model_UserTable::getInstance()-&amp;gt;find($id);&lt;br/&gt;
		$user-&amp;gt;refresh(true);&lt;br/&gt;
		assert($user-&amp;gt;City-&amp;gt;name == &apos;Mainz&apos;);	&lt;/p&gt;

&lt;p&gt;The last assert failse. I realized the problem while updating just a referenz using the fromArray() method like $user-&amp;gt;City-&amp;gt;fromArray(). The city would be saved correctly in DB but the foreign key in the user table would not be updated. After debugging I recognized that the $user is not replaced in UnitOfWork::saveGraph() because the $user is still in CLEAN state.&lt;/p&gt;

&lt;p&gt;Using &quot; $user-&amp;gt;coreSetRelated(&apos;Country&apos;, $user-&amp;gt;Country);&quot; or &quot;$user-&amp;gt;state(Doctrine_Record::STATE_DIRTY);&quot; after &quot;$user-&amp;gt;City-&amp;gt;name = &apos;Mainz&apos;&quot; would fix the prob in this case. As well as creating a new City instance an set $user-&amp;gt;City with this instance like:&lt;/p&gt;

&lt;p&gt;                $city = new Model_City();&lt;br/&gt;
                $city-&amp;gt;name = &apos;Mainz&apos;;&lt;br/&gt;
                $user-&amp;gt;City = $city;&lt;/p&gt;

&lt;p&gt;Also $user-&amp;gt;isModified(true) is true. So I fixed the issues in my case by changing the state of my records to DIRTY if the &quot;$this-&amp;gt;state() == CLEAN &amp;amp;&amp;amp; $user-&amp;gt;isModified(true) == true&quot; in the preSave() method of an abstract class that my Base classes are extending....&lt;/p&gt;</description>
                <environment>Ubuntu 9.04, PHP 5.2.6, MySQL 5.1, Zend Framework</environment>
            <key id="11363">DC-684</key>
            <summary>After adding a Reference, the ForeignKeys in the DB are not updatet</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="lk2.0">Lars Kosubek</reporter>
                        <labels>
                    </labels>
                <created>Fri, 14 May 2010 15:02:09 +0000</created>
                <updated>Tue, 26 Oct 2010 08:13:33 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Record</component>
                <component>Relations</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="14380" author="mars105" created="Wed, 15 Sep 2010 09:12:04 +0000"  >&lt;p&gt;Spend the last hour trying to get a workaround on this one.&lt;/p&gt;

&lt;p&gt;It apear to me that the solution is not easy. The object is modified while in STATE_LOCKED state, meaning that any state change in Record::_set() is not passed back to UnitOfWork::saveGraph() and therfor not saved in the database.&lt;/p&gt;

&lt;p&gt;Finaly I&apos;ve managed to make a realy dirty fix, I&apos;ll attach it if it come handy to somebody.&lt;br/&gt;
Keep in mind this is only a workaround and has NOT been tested. Use at your own risk...&lt;/p&gt;</comment>
                    <comment id="14381" author="mars105" created="Wed, 15 Sep 2010 09:13:00 +0000"  >&lt;p&gt;Dirty fix, see comments.&lt;br/&gt;
! NOT tested thoroughly !&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10797" name="DC_684_dirty_fix.patch" size="1490" author="mars105" created="Wed, 15 Sep 2010 09:13:00 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-666] Unable to create relations with several fields</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-666</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I have 2 tables.&lt;/p&gt;

&lt;p&gt;t1 :&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;id &lt;span class=&quot;error&quot;&gt;&amp;#91;Primary Key&amp;#93;&lt;/span&gt;&lt;br/&gt;
field1&lt;br/&gt;
field2&lt;br/&gt;
...&lt;br/&gt;
fieldn&lt;br/&gt;
t2_id &lt;span class=&quot;error&quot;&gt;&amp;#91;related to t2.id&amp;#93;&lt;/span&gt;&lt;br/&gt;
&amp;#8212;&lt;br/&gt;
primary key: id&lt;/p&gt;

&lt;p&gt;t2:&lt;br/&gt;
&amp;#8212;&lt;br/&gt;
id &lt;span class=&quot;error&quot;&gt;&amp;#91;related to t1.t2_id&amp;#93;&lt;/span&gt;&lt;br/&gt;
fixed_set &lt;span class=&quot;error&quot;&gt;&amp;#91;predefined set of values (for example &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;c&amp;quot;)&amp;#93;&lt;/span&gt;&lt;br/&gt;
field1&lt;br/&gt;
field2&lt;br/&gt;
...&lt;br/&gt;
fieldn&lt;br/&gt;
&amp;#8212;&lt;br/&gt;
primary key: id + fixed_set&lt;/p&gt;

&lt;p&gt;I need to use relation like follows:&lt;br/&gt;
SELECT * &lt;br/&gt;
FROM t1&lt;br/&gt;
LEFT JOIN t2 ON (t1.t2_id = t2.id AND t2.fixed_set = &quot;a&quot;)&lt;/p&gt;

&lt;p&gt;There is followed text in phpdoc from Relation.php:&lt;br/&gt;
&amp;#8212;&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;local                   the local field(s)&lt;br/&gt;
     *&lt;/li&gt;
	&lt;li&gt;foreign                 the foreign reference field(s)&lt;br/&gt;
&amp;#8212;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;But it is unable to use several fields in &quot;local&quot; and &quot;foreign&quot;, only one &quot;local&quot; and &quot;foreign&quot; field.&lt;/p&gt;</description>
                <environment>Windows Server 2003 SP2&lt;br/&gt;
Apache 2.2.14&lt;br/&gt;
PHP 5.3.1&lt;br/&gt;
Doctrine 1.2.2</environment>
            <key id="11320">DC-666</key>
            <summary>Unable to create relations with several fields</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="pavel">Pavel</reporter>
                        <labels>
                    </labels>
                <created>Wed, 5 May 2010 11:03:01 +0000</created>
                <updated>Sat, 7 Aug 2010 15:38:53 +0000</updated>
                                    <version>1.2.0-ALPHA1</version>
                <version>1.2.0-ALPHA2</version>
                <version>1.2.0-ALPHA3</version>
                <version>1.2.0-BETA1</version>
                <version>1.2.0-BETA2</version>
                <version>1.2.0-BETA3</version>
                <version>1.2.0-RC1</version>
                <version>1.2.0</version>
                <version>1.2.1</version>
                <version>1.2.2</version>
                <version>1.2.3</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-652] unidirectionnal hasMany definition</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-652</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Here the definition of the Domain Model : &lt;a href=&quot;http://pastebin.com/i80d73s8&quot; class=&quot;external-link&quot;&gt;http://pastebin.com/i80d73s8&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To resume, Show is a mother class. Video, is a direct extend from Show.&lt;br/&gt;
ShowContainer  is an abstract class that expend Show. It define an hasMany relation to Video, through CompoShowShow.&lt;br/&gt;
Program and Playlist are extends ShowContainer.&lt;/p&gt;

&lt;p&gt;the following DQL Query work fine.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$query	= Doctrine_Query::create ()&lt;br/&gt;
	-&amp;gt;from (&quot;Model_Program program&quot;)&lt;br/&gt;
	-&amp;gt;leftJoin (&quot;program.children children&quot;);&lt;br/&gt;
$oShow = $query-&amp;gt;fetchOne ();&lt;br/&gt;
var_dump (get_class ($oShow-&amp;gt;children&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;)); //Output Model_Video&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;But, the following code isn&apos;t working :&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$oProgram			= Doctrine_Core::getTable (&quot;Model_Program&quot;)-&amp;gt;find (2);&lt;br/&gt;
$oProgram-&amp;gt;children;&lt;/p&gt;

&lt;p&gt;//Throw Exception&lt;br/&gt;
//Message: Unknown record property / related component &quot;children&quot; on &quot;Model_Program&quot; &lt;br/&gt;
//Doctrine\Record.php(1381)&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;The Program#2 is in the database.&lt;/p&gt;

&lt;p&gt;Here we are.&lt;/p&gt;</description>
                <environment></environment>
            <key id="11276">DC-652</key>
            <summary>unidirectionnal hasMany definition</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="armetiz">Thomas Tourlourat - Armetiz</reporter>
                        <labels>
                    </labels>
                <created>Tue, 27 Apr 2010 10:22:27 +0000</created>
                <updated>Mon, 14 Jun 2010 09:29:07 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="13203" author="jwage" created="Tue, 8 Jun 2010 16:17:14 +0000"  >&lt;p&gt;We&apos;ll need some more information. I don&apos;t see the Model_Program model anywhere. Can you create a failing test case?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-651] [PATCH] Doctrine_Record::option(&apos;orderBy&apos;, ...) of join&apos;s right side being applied to refTable in m2m relationship</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-651</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When using the &lt;tt&gt;Doctrine_Record::option(&apos;orderBy&apos;, ...)&lt;/tt&gt; feature on a table definition, where that table is the target of a many-to-many join, the specified orderBy columns are applied to the relation table&apos;s alias. So for example, given the following definitions:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;class User &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record {
  &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition() {
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;uid&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(&apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;option(&apos;orderBy&apos;, &apos;uid&apos;);
  }

  &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp() {
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasMany(&apos;Group as groups&apos;, array(&apos;refClass&apos; =&amp;gt; &apos;UserGroup&apos;, &apos;local&apos; =&amp;gt; &apos;user_uid&apos;, &apos;foreign&apos; =&amp;gt; &apos;group_id&apos;));
  }
}

class Group &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record {
  &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition() {
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;gid&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(&apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
  }

  &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp() {
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasMany(&apos;User as users&apos;, array(&apos;refClass&apos; =&amp;gt; &apos;UserGroup&apos;, &apos;local&apos; =&amp;gt; &apos;group_gid&apos;, &apos;foreign&apos; =&amp;gt; &apos;user_id&apos;));
  }
}

class UserGroup &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record {
  &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition() {
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;user_uid&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(&apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;group_gid&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(&apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
  }

  &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp() {
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasOne(&apos;User as user&apos;, array(&apos;local&apos; =&amp;gt; &apos;user_uid&apos;, &apos;foreign&apos; =&amp;gt; &apos;uid&apos;));
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasOne(&apos;Group as group&apos;, array(&apos;local&apos; =&amp;gt; &apos;group_gid&apos;, &apos;foreign&apos; =&amp;gt; &apos;gid&apos;));
  }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;the following queries:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$query = Doctrine_Query::create()
  -&amp;gt;select(&apos;u.*&apos;)
  -&amp;gt;from(&apos;User u&apos;)
  -&amp;gt;leftJoin(&apos;u.groups g WITH g.gid=?&apos;, 1);
echo $query-&amp;gt;getSqlQuery() . &lt;span class=&quot;code-quote&quot;&gt;&quot;\n&quot;&lt;/span&gt;;

$query = Doctrine_Query::create()
  -&amp;gt;select(&apos;g.*&apos;)
  -&amp;gt;from(&apos;Group g&apos;)
  -&amp;gt;leftJoin(&apos;g.users u WITH u.uid=?&apos;, 1);
echo $query-&amp;gt;getSqlQuery() . &lt;span class=&quot;code-quote&quot;&gt;&quot;\n&quot;&lt;/span&gt;;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;will output the following:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;SELECT u.uid AS u__uid FROM user u LEFT JOIN user_group u2 ON (u.uid = u2.user_uid) LEFT JOIN group g ON g.gid = u2.group_id AND (g.gid = ?) ORDER BY u.uid&lt;br/&gt;
SELECT g.gid AS g__gid FROM group g LEFT JOIN user_group u2 ON (g.gid = u2.group_gid) LEFT JOIN user u ON u.uid = u2.user_id AND (u.uid = ?) ORDER BY u.uid, u2.uid&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;The &lt;tt&gt;orderBy&lt;/tt&gt; &lt;tt&gt;option()&lt;/tt&gt; call is applied to the &lt;tt&gt;User&lt;/tt&gt; definition. The SQL for the first query is correct (where &lt;tt&gt;User&lt;/tt&gt; is on the left side of the join). The SQL for the second query (where &lt;tt&gt;User&lt;/tt&gt; is on the right-most side of the join), however, is obviously incorrect (&lt;tt&gt;UserGroup&lt;/tt&gt; doesn&apos;t even have a &lt;tt&gt;uid&lt;/tt&gt; column). Basically, &lt;tt&gt;User&lt;/tt&gt;&apos;s &lt;tt&gt;orderBy&lt;/tt&gt; option is being applied to both the &lt;tt&gt;User&lt;/tt&gt; table and its respective reference table, &lt;tt&gt;UserGroup&lt;/tt&gt;, when it is the target of a join.&lt;/p&gt;

&lt;p&gt;After digging through the source for a while, I believe I&apos;ve come up with a patch for this issue (which should be checked by someone more knowledgeable of Doctrine&apos;s internals). Basically, in the &lt;tt&gt;Doctrine_Query::buildSqlQuery()&lt;/tt&gt; function, a call is made to &lt;tt&gt;Doctrine_Relation::getOrderByStatement()&lt;/tt&gt; with the reference table (&lt;tt&gt;UserGroup&lt;/tt&gt;)&apos;s alias (&lt;tt&gt;u2&lt;/tt&gt;), which in turn makes a call to &lt;tt&gt;Doctrine_Table::getOrderByStatement()&lt;/tt&gt; on the referenced table (&lt;tt&gt;User&lt;/tt&gt;), filling in the &lt;tt&gt;ORDER BY&lt;/tt&gt; clause with &lt;tt&gt;User&lt;/tt&gt; columns using &lt;tt&gt;UserGroup&lt;/tt&gt;&apos;s alias. My solution was to reorder the logic so that the test for a reference class is made before the initial call to &lt;tt&gt;getOrderByStatement()&lt;/tt&gt; is made. It seems to work against my test case and the test cases in the repository. I&apos;ll post my patch momentarily.&lt;/p&gt;

&lt;p&gt;This bug was first mentioned in the comments in &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-313&quot; title=&quot;Ordering m2m relationship with column from related table (with orderBy option)&quot;&gt;DC-313&lt;/a&gt;, but the original ticket comes across as more of a feature request for the &lt;tt&gt;hasMany()&lt;/tt&gt; &lt;tt&gt;orderBy&lt;/tt&gt; feature.&lt;/p&gt;</description>
                <environment>CentOS 5.4&lt;br/&gt;
PHP 5.3.2&lt;br/&gt;
MySQL 5.1.44, for unknown-linux-gnu (x86_64)</environment>
            <key id="11270">DC-651</key>
            <summary>[PATCH] Doctrine_Record::option(&apos;orderBy&apos;, ...) of join&apos;s right side being applied to refTable in m2m relationship</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="guilhermeblanco">Guilherme Blanco</assignee>
                                <reporter username="suhock">suhock</reporter>
                        <labels>
                    </labels>
                <created>Mon, 26 Apr 2010 12:22:21 +0000</created>
                <updated>Wed, 31 Aug 2011 12:43:09 +0000</updated>
                                    <version>1.2.2</version>
                <version>1.2.3</version>
                                <fixVersion>1.2.2</fixVersion>
                <fixVersion>1.2.3</fixVersion>
                <fixVersion>1.2.4</fixVersion>
                                <component>Query</component>
                <component>Relations</component>
                        <due></due>
                    <votes>2</votes>
                        <watches>4</watches>
                        <comments>
                    <comment id="12750" author="suhock" created="Mon, 26 Apr 2010 12:45:12 +0000"  >&lt;p&gt;attached a test case for this bug&lt;/p&gt;</comment>
                    <comment id="12751" author="suhock" created="Mon, 26 Apr 2010 13:01:03 +0000"  >&lt;p&gt;patch against /branches/1.2 HEAD (should also work apply to 1.2.2 tag)&lt;/p&gt;</comment>
                    <comment id="14179" author="dordille" created="Mon, 30 Aug 2010 17:22:44 +0000"  >&lt;p&gt;I can confirm this as an issue.  However I don&apos;t think the above patch adequately fixes the problem it seems like with it an order by is still added for the ref column however the relation alias is lost.&lt;/p&gt;

&lt;p&gt;My query with the patch became&lt;br/&gt;
SELECT g.gid AS g__gid FROM group g LEFT JOIN user_group u2 ON (g.gid = u2.group_gid) LEFT JOIN user u ON u.uid = u2.user_id AND (u.uid = ?) ORDER BY u.uid, uid &lt;/p&gt;

&lt;p&gt;I made an another patch that prevents this extra order by clause from being added and have attached it.&lt;/p&gt;
</comment>
                    <comment id="14428" author="suhock" created="Tue, 21 Sep 2010 08:53:25 +0000"  >&lt;p&gt;I tried out the new patch (Query_orderby_relation.diff), but it provides a reversed diff (patching goes from a patched version to the original). After applying it manually, it fails the provided test case and several additional test cases from the repository.&lt;/p&gt;

&lt;p&gt;The original patch DOES pass the provided test case, when applied against 1.2.2, 1.2.3, or the 1.2 branch from the repository. It does not pass, however, Doctrine_Query_Orderby_TestCase. As the previous poster mentioned, it fails to resolve aliases in instances where the &apos;orderBy&apos; option is specified in a relation definition.&lt;/p&gt;

&lt;p&gt;I deleted the original patch and am providing a revised patch (Ticket_DC651.patch) against branch 1.2 HEAD (also works with 1.2.3), which fixes this issue. It passes all working test cases, including Doctrine_Query_Orderby_TestCase and DC651TestCase.&lt;/p&gt;</comment>
                    <comment id="16406" author="deraujoj" created="Wed, 31 Aug 2011 12:43:08 +0000"  >&lt;p&gt;I had this issue recently on a application I&apos;m working on as described the oderBy option was applied on the joined table on a column that even doesn&apos;t exist in it. I used the DC651 patch provided and it solved the issue, so far I haven&apos;t seen any side effect to it. &lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10585" name="DC651TestCase.php" size="3335" author="suhock" created="Mon, 26 Apr 2010 12:45:12 +0000" />
                    <attachment id="10751" name="Query_orderBy_relation.diff" size="1122" author="dordille" created="Mon, 30 Aug 2010 17:22:56 +0000" />
                    <attachment id="10806" name="Ticket_DC651.patch" size="1448" author="suhock" created="Tue, 21 Sep 2010 08:53:25 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-637] Many-to-many: Using Association Class (refclass) property in query adds leftJoin</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-637</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When trying to use a refclass property - i.e. normalization table column - in a query, an unnecessary join is added to the query created, which is then used to &quot;access&quot; the property.&lt;/p&gt;

&lt;p&gt;This issue has already been discussed back in May 2008 but still seems to persist.&lt;br/&gt;
Please see the google group discussion &lt;a href=&quot;http://groups.google.com/group/doctrine-user/browse_thread/thread/c655832a450ccd1a/9cb6eca6ae1c3dee&quot; class=&quot;external-link&quot;&gt;http://groups.google.com/group/doctrine-user/browse_thread/thread/c655832a450ccd1a/9cb6eca6ae1c3dee&lt;/a&gt; for example + comments.&lt;/p&gt;

&lt;p&gt;Unfortunately it is hardly possible to write a test case for this, as working SQL is generated, but the query is just not right (test case basically would have to assert the query string, wich does not make much sense).&lt;br/&gt;
Another way to test if it does &quot;what it should&quot;, could be to assert contents of $q-&amp;gt;getTableAliasMap() - but does not seem ideal either.&lt;/p&gt;

&lt;p&gt;John Wage commented on this issue &lt;br/&gt;
&quot;Can you create a ticket for this with a failing test case? I believe this&lt;br/&gt;
should be possible and we should investigate a fix for it. &lt;br/&gt;
Thanks, Jon &quot;&lt;br/&gt;
&lt;a href=&quot;http://groups.google.com/group/doctrine-user/browse_thread/thread/c655832a450ccd1a/9cb6eca6ae1c3dee#msg_c73934a38515cadb&quot; class=&quot;external-link&quot;&gt;http://groups.google.com/group/doctrine-user/browse_thread/thread/c655832a450ccd1a/9cb6eca6ae1c3dee#msg_c73934a38515cadb&lt;/a&gt;&lt;/p&gt;</description>
                <environment>PHP 5.3.2 (cli) (built: Mar  4 2010 22:12:20)&lt;br/&gt;
mysql 5.1.45&lt;br/&gt;
centOS</environment>
            <key id="11246">DC-637</key>
            <summary>Many-to-many: Using Association Class (refclass) property in query adds leftJoin</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="guilhermeblanco">Guilherme Blanco</assignee>
                                <reporter username="grass">Pablo Grass</reporter>
                        <labels>
                    </labels>
                <created>Tue, 20 Apr 2010 06:31:54 +0000</created>
                <updated>Tue, 20 Apr 2010 06:39:21 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                    <attachment id="10581" name="example.php" size="1782" author="grass" created="Tue, 20 Apr 2010 06:31:54 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-628] Two queries on the same table seems to share set of fields </title>
                <link>http://www.doctrine-project.org/jira/browse/DC-628</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Two queries:&lt;/p&gt;

&lt;p&gt;1.              $ab1 = Doctrine_Query::create()&lt;br/&gt;
                        -&amp;gt;from(&apos;Model_UserAddressbook ab&apos;)&lt;br/&gt;
                        -&amp;gt;leftJoin(&apos;ab.UserPersons up&apos;)&lt;br/&gt;
                        -&amp;gt;leftJoin(&apos;ab.AdminUsers au&apos;);  // second one doesn&apos;t have this join&lt;/p&gt;

&lt;p&gt;2.              $ab2 = Doctrine_Query::create()&lt;br/&gt;
                        -&amp;gt;from(&apos;Model_UserAddressbook ab&apos;)&lt;br/&gt;
                        -&amp;gt;leftJoin(&apos;ab.UserPersons up&apos;);&lt;/p&gt;

&lt;p&gt;When executing the following fetchOne:&lt;/p&gt;

&lt;p&gt;A.) $x1 = $ab2-&amp;gt;fetchOne()-&amp;gt;toArray();  // has fields from addressbook, and subarray UserPersons, OK&lt;br/&gt;
B.) $x2 = $ab1-&amp;gt;fetchOne()-&amp;gt;toArray();  // has fields from addressbook, and subarray UserPersons and AdminUsers, OK&lt;br/&gt;
C.) $x3 = $ab2-&amp;gt;fetchOne()-&amp;gt;toArray();  // has fields from addressbook, and subarray UserPersons and AdminUsers, NOT OK&lt;/p&gt;

&lt;p&gt;$x1 and $x3 should have the same set of fields, but $x3 has somehow received set of fields from $x2.&lt;/p&gt;

&lt;p&gt;I haven&apos;t turned on any caching, but even if the caching is on, the result sets shouldn&apos;t mix, right?&lt;/p&gt;

&lt;p&gt;I&apos;m talking just about field names (set of fields), not fields data.&lt;/p&gt;</description>
                <environment>OS: Vista 64&lt;br/&gt;
Zend Framework 1.10.1&lt;br/&gt;
MySQL: 5.1.39</environment>
            <key id="11217">DC-628</key>
            <summary>Two queries on the same table seems to share set of fields </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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="vlatko">Vlatko Basic</reporter>
                        <labels>
                    </labels>
                <created>Wed, 14 Apr 2010 04:42:03 +0000</created>
                <updated>Mon, 14 Jun 2010 09:24:49 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-601] When using a join and giving an alias to each select column the hyrdrator only returns one row.</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-601</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Hi All &lt;br/&gt;
I am running into a strange problem using Doctrine-1.2.2-- I have a  multi row result set but only the first row of it is returned in the hyrdated array that is generated. &lt;br/&gt;
I have tracked this down in the code to get a basic idea of whats going on &amp;#8211; it seems that the $id variable in the hydrateResultSet function in Doctrine_Hydrator_Graph isn&apos;t being populated properly with data about the fields that are returning from my query. The _gatherRowData function seems to never detect that one of my columns is an identifier (&quot;if ($cache&lt;span class=&quot;error&quot;&gt;&amp;#91;$key&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;isIdentifier&amp;#39;&amp;#93;&lt;/span&gt;) &lt;/p&gt;
{&quot; doesn&apos;t return true ever so the next line of code: &quot;$id[$dqlAlias] .= &apos;|&apos; . $value;&quot; doesn&apos;t run). 
I think this is the problem but I don&apos;t totally understand how the mapping process is taking place in this function so can&apos;t be absolutely sure. 

This hydration problem goes away if I don&apos;t use left joins in my query, or if I use a query where not every field I am requesting is assigned an alias (at least one of the fields doesn&apos;t use the &apos;as&apos; syntax). 
For instance this php: 
{code}
&lt;p&gt;$q = Doctrine_Query::create(); &lt;br/&gt;
$q-&amp;gt;from(&apos;Customer Customer&apos;); &lt;br/&gt;
$q-&amp;gt;leftJoin(&apos;Customer.Zip Zip&apos;); &lt;br/&gt;
$q-&amp;gt;addSelect(&apos;Customer.firstname as first_name&apos;); &lt;br/&gt;
$q-&amp;gt;addSelect(&apos;Customer.postalcode as postalcode&apos;); &lt;br/&gt;
$q-&amp;gt;setHydrationMode(Doctrine::HYDRATE_ARRAY); &lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;Generates &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; DQL: 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;SELECT Customer.firstname as first_name, Customer.postalcode as postalcode FROM Customer Customer LEFT JOIN Customer.Zip Zip&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;And &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; SQL:
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;SELECT c.firstname AS c_&lt;em&gt;0, c.postalcode AS c&lt;/em&gt;_1 FROM customers c LEFT JOIN zips z ON c.postalcode = z.postalcode&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;Which results in &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; after hyrdration: 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;array(&apos;0&apos;=&amp;gt;array(&apos;first_name&apos;=&amp;gt;&apos;Armando&apos;, &apos;postalcode&apos;=&amp;gt;&apos;00659&apos;)) &lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
However the following code hydrates just fine: 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;$q = Doctrine_Query::create(); &lt;br/&gt;
$q-&amp;gt;from(&apos;Customer Customer&apos;); &lt;br/&gt;
$q-&amp;gt;addSelect(&apos;Customer.firstname as first_name&apos;); &lt;br/&gt;
$q-&amp;gt;setHydrationMode(Doctrine::HYDRATE_ARRAY); &lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;As does &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; code: 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;$q = Doctrine_Query::create(); &lt;br/&gt;
$q-&amp;gt;from(&apos;Customer Customer&apos;); &lt;br/&gt;
$q-&amp;gt;leftJoin(&apos;Customer.Zip Zip&apos;); &lt;br/&gt;
$q-&amp;gt;addSelect(&apos;Customer.firstname&apos;); &lt;br/&gt;
$q-&amp;gt;addSelect(&apos;Customer.postalcode as postalcode&apos;); &lt;br/&gt;
$q-&amp;gt;setHydrationMode(Doctrine::HYDRATE_ARRAY); &lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
Here is the yaml &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; the sample data I am testing on: 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt; detect_relations: false&lt;br/&gt;
 package: Example&lt;br/&gt;
 options:&lt;br/&gt;
   type: INNODB&lt;br/&gt;
   charset: utf8&lt;br/&gt;
 Customer:&lt;br/&gt;
   tableName: customers&lt;br/&gt;
   columns:&lt;br/&gt;
     customer_id:&lt;br/&gt;
       type: integer(4)&lt;br/&gt;
       primary: true&lt;br/&gt;
       notnull: true&lt;br/&gt;
       autoincrement: true&lt;br/&gt;
     firstname:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
     lastname:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
     streetaddress:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
     city:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
     state:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
     postalcode:&lt;br/&gt;
       type: string(45)&lt;br/&gt;
   relations:&lt;br/&gt;
     Order:&lt;br/&gt;
       type: many&lt;br/&gt;
       local: customer_id&lt;br/&gt;
       foreign: customer_id&lt;br/&gt;
     Zip:&lt;br/&gt;
       type: one&lt;br/&gt;
       local: postalcode&lt;br/&gt;
       foreign: postalcode&lt;br/&gt;
   options:&lt;br/&gt;
     type: InnoDB&lt;br/&gt;
 Zip:&lt;br/&gt;
   connection: default_schema&lt;br/&gt;
   tableName: zips&lt;br/&gt;
   columns:&lt;br/&gt;
     postalcode:&lt;br/&gt;
       type: varchar(30)&lt;br/&gt;
       primary: true&lt;br/&gt;
     latitude: &apos;float(10,6)&apos;&lt;br/&gt;
     longitude: &apos;float(10,6)&apos;&lt;br/&gt;
     city: string(50)&lt;br/&gt;
     state: string(50)&lt;br/&gt;
     country: string(50)&lt;br/&gt;
     type: string(50)&lt;br/&gt;
   relations:&lt;br/&gt;
     Customer:&lt;br/&gt;
       type: many&lt;br/&gt;
       local: postalcode&lt;br/&gt;
       foreign: postalcode&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Perhaps there is something simple I am overlooking. To get around this I am just always selecting the primary key from my main table in every query.&lt;/p&gt;

&lt;p&gt;Thanks in advance for any advice.&lt;br/&gt;
Will Ferrer&lt;/p&gt;</description>
                <environment>XP Xamp</environment>
            <key id="11139">DC-601</key>
            <summary>When using a join and giving an alias to each select column the hyrdrator only returns one row.</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="guilhermeblanco">Guilherme Blanco</assignee>
                                <reporter username="willf1976">will ferrer</reporter>
                        <labels>
                    </labels>
                <created>Thu, 25 Mar 2010 19:32:28 +0000</created>
                <updated>Mon, 2 Aug 2010 02:45:07 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Query</component>
                <component>Relations</component>
                        <due></due>
                    <votes>2</votes>
                        <watches>3</watches>
                        <comments>
                    <comment id="12564" author="willf1976" created="Sat, 3 Apr 2010 18:13:13 +0000"  >&lt;p&gt;This problem also exists in 1.2.2 so I have updated the post to reflect this.&lt;/p&gt;</comment>
                    <comment id="12582" author="naag" created="Tue, 6 Apr 2010 08:30:00 +0000"  >&lt;p&gt;I experienced the same problem with Doctrine 1.2 (r7329). I also fixed this by adding the primary key of the table I select from to the select list.&lt;/p&gt;</comment>
                    <comment id="12603" author="willf1976" created="Wed, 7 Apr 2010 20:20:21 +0000"  >&lt;p&gt;Hi Peter&lt;/p&gt;

&lt;p&gt;Thats how I am currently working around the bug as well but hopefully it will get rectified in a later version of doctrine.&lt;/p&gt;

&lt;p&gt;Thanks for the comment.&lt;/p&gt;

&lt;p&gt;Will&lt;/p&gt;</comment>
                    <comment id="13139" author="somedoun" created="Tue, 8 Jun 2010 09:08:54 +0000"  >&lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;I&apos;m new to doctrine and since yesterday, I&apos;m experiencing exactly the same behavior.&lt;br/&gt;
Any news about this subject ? Is there a doctrine version where the pb is solved ? &lt;br/&gt;
Help !&lt;/p&gt;

&lt;p&gt;Regards,&lt;br/&gt;
Doun&lt;/p&gt;</comment>
                    <comment id="13239" author="willf1976" created="Tue, 8 Jun 2010 19:13:11 +0000"  >&lt;p&gt;Hi Sam&lt;/p&gt;

&lt;p&gt;Currently I am working around this bug by always adding the primary key of the table to the select (like peter also mentions above).&lt;/p&gt;

&lt;p&gt;It is a work around for the problem but so far it has been reliable for me.&lt;/p&gt;

&lt;p&gt;I hope that helps until there is a patch for it.&lt;/p&gt;

&lt;p&gt;Will Ferrer&lt;/p&gt;</comment>
                    <comment id="13246" author="somedoun" created="Wed, 9 Jun 2010 05:18:14 +0000"  >&lt;p&gt;Hi Will&lt;/p&gt;

&lt;p&gt;I&apos;ll do so.&lt;br/&gt;
Thank you VM.&lt;/p&gt;

&lt;p&gt;Sam Doun&lt;/p&gt;</comment>
                    <comment id="13756" author="shuchi" created="Mon, 2 Aug 2010 02:26:10 +0000"  >&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;Has there been any patch release for the same? &lt;br/&gt;
We just upgraded from Doctrine 1.1 to 1.2 and our project now crashes.&lt;/p&gt;

&lt;p&gt;For DQL - &lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;function getServiceDetails($merchantId,$merchantServiceId) {
    $q = Doctrine_Query::create()
        -&amp;gt;select(&apos;b.*, m.name as merchant_service_name,payment_mode.name as payment_mode_name,payment_mode.id as paymentMode,p.id as paymentModeOption &apos;)
        -&amp;gt;from(&apos;ServicePaymentModeOption b&apos;)
        -&amp;gt;leftJoin(&quot;b.MerchantService m&quot;)
        -&amp;gt;leftJoin(&quot;m.Merchant merchant&quot;)
        -&amp;gt;leftJoin(&quot;b.PaymentModeOption p&quot;)
        -&amp;gt;leftJoin(&quot;p.PaymentMode payment_mode&quot;)
        -&amp;gt;where(&quot;merchant.id=?&quot;,$merchantId)
        -&amp;gt;andWhere(&quot;b.merchant_service_id=?&quot;,$merchantServiceId)
        -&amp;gt;groupBy(&apos;p.name&apos;);

    return $res = $q-&amp;gt;execute(array(),Doctrine::HYDRATE_ARRAY);
  }  
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;Result with Doctrine 1.1 is&lt;/b&gt;&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;Array
(
    [0] =&amp;gt; Array
        (
            [id] =&amp;gt; 1
            [merchant_service_id] =&amp;gt; 1
            [payment_mode_option_id] =&amp;gt; 1
            [created_at] =&amp;gt;
            [updated_at] =&amp;gt;
            [deleted] =&amp;gt;
            [created_by] =&amp;gt;
            [updated_by] =&amp;gt;
            [merchant_service_name] =&amp;gt; NIS Passport
            [merchant_name] =&amp;gt; NIS
            [payment_mode_option_name] =&amp;gt; Bank
            [payment_mode_name] =&amp;gt; Bank
            [paymentMode] =&amp;gt; 1
            [paymentModeOption] =&amp;gt; 1
            [MerchantService] =&amp;gt; Array
                (
                    [merchant_service_name] =&amp;gt; NIS Passport
                    [Merchant] =&amp;gt; Array
                        (
                            [merchant_name] =&amp;gt; NIS
                        )

                )

            [PaymentModeOption] =&amp;gt; Array
                (
                    [payment_mode_option_name] =&amp;gt; Bank
                    [paymentModeOption] =&amp;gt; 1
                    [PaymentMode] =&amp;gt; Array
                        (
                            [payment_mode_name] =&amp;gt; Bank
                            [paymentMode] =&amp;gt; 1
                        )

                )

        )
)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;Result with Doctrine 1.2 is&lt;/b&gt;&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;Array
(
    [0] =&amp;gt; Array
        (
            [id] =&amp;gt; 1
            [merchant_service_id] =&amp;gt; 1
            [payment_mode_option_id] =&amp;gt; 1
            [created_at] =&amp;gt;
            [updated_at] =&amp;gt;
            [deleted_at] =&amp;gt;
            [created_by] =&amp;gt;
            [updated_by] =&amp;gt;
            [merchant_service_name] =&amp;gt; NIS Passport
            [merchant_name] =&amp;gt; NIS
            [payment_mode_option_name] =&amp;gt; Bank
            [payment_mode_name] =&amp;gt; Bank
            [paymentMode] =&amp;gt; 1
            [paymentModeOption] =&amp;gt; 1
        )
)

&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We have used Hydration for the result set at lot of places. Please suggest if there could be a fix without going about revising everything that has been coded.&lt;/p&gt;

&lt;p&gt;Looking forward to a quick response.&lt;/p&gt;





</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-587] Problem with non equal self referencing many to many relations</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-587</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I think that this bug has been reported already here:&lt;br/&gt;
&lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-329?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel&quot; class=&quot;external-link&quot;&gt;http://www.doctrine-project.org/jira/browse/DC-329?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel&lt;/a&gt;&lt;br/&gt;
But I thought that it might be useful to submit a very simple test case, with the bug completely isolated.&lt;br/&gt;
When you create a self referenced non equal many-to-many relation like: person has many parents AND has many children (taken from the documentation).&lt;/p&gt;

&lt;p&gt;In the attached test case, after both collections of related records are altered within the foreach statement, Doctrine somehow messes up the Ids in the reference class. Now, it&apos;s important to note, that if you loop through just one of the collections, it won&apos;t fail.&lt;/p&gt;

&lt;p&gt;Thanks in advance!&lt;/p&gt;</description>
                <environment>Windows 7600 / Linux / PHP 5.2.13 / PHP 5.3.0</environment>
            <key id="11090">DC-587</key>
            <summary>Problem with non equal self referencing many to many relations</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="lilawolf">Nil Null</reporter>
                        <labels>
                    </labels>
                <created>Thu, 18 Mar 2010 22:10:26 +0000</created>
                <updated>Tue, 8 Jun 2010 16:18:20 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                    <attachment id="10498" name="person.php" size="1102" author="lilawolf" created="Thu, 18 Mar 2010 22:10:26 +0000" />
                    <attachment id="10499" name="relation.php" size="506" author="lilawolf" created="Thu, 18 Mar 2010 22:10:26 +0000" />
                    <attachment id="10500" name="test.php" size="350" author="lilawolf" created="Thu, 18 Mar 2010 22:10:26 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-502] sometimes not all the constraints are created for a many to many relation</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-502</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;it seems that the naming is important:&lt;/p&gt;

&lt;p&gt;in a User, Group, UserGroup relation (where the UserGroup defines the many to many relation for User &amp;amp; Group) the constraints are defined well&lt;/p&gt;

&lt;p&gt;but if the tables are Order, Service, OrderService it doesn&apos;t work =&amp;gt; just one constraint is created... please find my example:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;schema.yml&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;Order:
  tableName:          orders
  columns:
    name:             string(50)
  relations:
    Services:
      class:          Service
      local:          order_id
      foreign:        service_id
      refClass:       OrderService

Service:
  actAs:
    Versionable:      ~
  columns:
    name:             string(50)
  relations:
    Orders:
      class:          Order
      local:          service_id
      foreign:        order_id
      refClass:       OrderService

# WTF: it takes alphbetically the constraints building  !?
# &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; I used ZorderService instead of OrderService, Z is after S (O is before S) the constraints are defined fine!
OrderService:
  columns:
    order_id:         { type: integer, primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt; }
    service_id:       { type: integer, primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt; }

&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt; ==&amp;gt; the generated SQL &lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;sql&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;CREATE TABLE orders (id BIGINT AUTO_INCREMENT, name VARCHAR(50), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE order_service (order_id BIGINT, service_id BIGINT, version BIGINT, PRIMARY KEY(order_id, service_id, 
        version)) ENGINE = INNODB;
CREATE TABLE service_version (id BIGINT, name VARCHAR(50), version BIGINT, PRIMARY KEY(id, version)) ENGINE = 
        INNODB;
CREATE TABLE service (id BIGINT AUTO_INCREMENT, name VARCHAR(50), version BIGINT, PRIMARY KEY(id)) ENGINE = 
        INNODB;
ALTER TABLE order_service ADD CONSTRAINT order_service_order_id_orders_id FOREIGN KEY (order_id) REFERENCES 
        orders(id);
ALTER TABLE service_version ADD CONSTRAINT service_version_id_service_id FOREIGN KEY (id) REFERENCES service(id) 
        ON UPDATE CASCADE ON DELETE CASCADE;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;=&amp;gt;  as you can see for TABLE order_service just one constraint is defined (&lt;b&gt;order_service_order_id_orders_id&lt;/b&gt;) the other one (&lt;b&gt;order_service_service_id_service_id&lt;/b&gt;) is missing !!!&lt;/p&gt;


&lt;p&gt;However if i change the names for tables (actually i think alphabetically order) and use ZorderService instead of OrderService (lik UserGroup for User &amp;amp; Group) the two constraints are created!&lt;/p&gt;

&lt;p&gt;This also affects the &quot;getRelations()&quot; when i tried to write a behavior (it gives back just one relation):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;  foreach ($event-&amp;gt;getInvoker()-&amp;gt;getTable()-&amp;gt;getRelations() as $relation)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;ps: &lt;br/&gt;
  also the same bug reported on the list: &lt;a href=&quot;http://groups.google.com/group/doctrine-user/browse_thread/thread/ad48db71b71e043b&quot; class=&quot;external-link&quot;&gt;http://groups.google.com/group/doctrine-user/browse_thread/thread/ad48db71b71e043b&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;sub&gt;(edit G.X: split too long lines in SQL code)&lt;/sub&gt;&lt;/p&gt;</description>
                <environment>i tried both under linux / win; with doctrine 1.1 / 1.2.1&lt;br/&gt;
tried with sandbox / direct creating &amp;quot;bootstrap&amp;quot; =&amp;gt; same results...</environment>
            <key id="10899">DC-502</key>
            <summary>sometimes not all the constraints are created for a many to many relation</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="rich">Papp Richard</reporter>
                        <labels>
                    </labels>
                <created>Mon, 15 Feb 2010 15:18:01 +0000</created>
                <updated>Mon, 14 Jun 2010 03:38:30 +0000</updated>
                                    <version>1.2.0-ALPHA1</version>
                <version>1.2.0-ALPHA2</version>
                <version>1.2.0-ALPHA3</version>
                <version>1.2.0-BETA1</version>
                <version>1.2.0-BETA2</version>
                <version>1.2.0-BETA3</version>
                <version>1.2.0-RC1</version>
                <version>1.2.0</version>
                <version>1.2.1</version>
                <version>1.2.2</version>
                                                <component>Import/Export</component>
                <component>Relations</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="12720" author="ryba" created="Tue, 20 Apr 2010 14:36:59 +0000"  >&lt;p&gt;I seem to have a very similar issue. It is really annoying because no error feedback is given at any point...&lt;br/&gt;
In my case, one out of three many-to-many relations actually has its constraints created, the other two not.&lt;br/&gt;
However, if I take the file date/sql/schema.sql (I am working with Symfony 1.4.4) and run as an SQL query directly with my database, the constraints are created properly!&lt;/p&gt;

&lt;p&gt;So, with symfony, if I go:&lt;br/&gt;
$ symfony14 doctrine:build-model&lt;br/&gt;
$ symfony14 doctrine:build-sql&lt;br/&gt;
$ symfony14 doctrine:insert-sql&lt;br/&gt;
The model gets generated, the database gets generated, but several many-to-many constrains are missing.&lt;/p&gt;

&lt;p&gt;Then if I go:&lt;br/&gt;
$ symfony14 doctrine:build-model&lt;br/&gt;
$ symfony14 doctrine:build-sql&lt;br/&gt;
$ mysql -u user -p database &amp;lt; date/sql/schema.sql&lt;br/&gt;
The model gets generated, the database gets generated, and the constraints are in place.&lt;/p&gt;

&lt;p&gt;Hope this helps to have the problem fixed.&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br/&gt;
Piotrek&lt;/p&gt;</comment>
                    <comment id="13273" author="gx" created="Fri, 11 Jun 2010 08:47:19 +0000"  >&lt;p&gt;I do confirm this &quot;alphabetical-order exporting&quot; problem! (in 1.2 svn revision 7676)&lt;br/&gt;
(see also #&lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DC-655&quot; title=&quot;When Export from Models to database is made some constraints may not be created&quot;&gt;DC-655&lt;/a&gt;)&lt;/p&gt;


&lt;p&gt;*&lt;b&gt;Edit:&lt;/b&gt;* I have gone closer through the functions calls and used a debugger, and the problem is actually logical;&lt;br/&gt;
it happens whenever a refClass of a many-to-many relation is parsed (and exported) before one or both of the linked classes.&lt;/p&gt;

&lt;p&gt;Let&apos;s take this schema (YAML is shorter, anyways the generated PHP models are not bugged):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;schema.yml&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-none&quot;&gt;---
LinkTable:
  columns:
    table1_id:
      primary: true
      type:    integer
    table2_id:
      primary: true
      type:    integer
Table1:
  relations:
    Table2:
      refClass: LinkTable
      local:    table1_id
      foreign:  table2_id
Table2:
  relations:
    Table1:
      refClass: LinkTable
      local:    table2_id
      foreign:  table1_id
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now if you call Doctrine_Core::createTablesFromModels() or Doctrine_Core::generateSqlFromModels(), consequent call to Doctrine_Export::exportSortedClassesSql() does a loop and calls exportClassesSql() for each model in alphabetical order; once a table has been exported, subsequent bindings of pending relations won&apos;t be &quot;retro-parsed&quot; for the export.&lt;/p&gt;

&lt;p&gt;I tried to compact the calls chain:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;php&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;/* IN CLASS Doctrine_Export (or child (connection export)) */

$&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;exportSortedClassesSql($classes)
{
    FOREACH ($classes as $class) {
        $connection = Doctrine_Manager::getInstance()-&amp;gt;getConnectionForComponent($class);
        &lt;span class=&quot;code-comment&quot;&gt;//...
&lt;/span&gt;        $sql =
        $connection-&amp;gt;export-&amp;gt;exportClassesSql($models = array($class))
        {
            FOREACH ($models as $name) {
                $record = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; $name();
                $table = $record-&amp;gt;getTable();
                &lt;span class=&quot;code-comment&quot;&gt;//...
&lt;/span&gt;                $data = $table-&amp;gt;getExportableFormat()
                {
                    /* IN CLASS Doctrine_Table (or child) */
                    
                    &lt;span class=&quot;code-comment&quot;&gt;//...
&lt;/span&gt;                    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_parser-&amp;gt;getRelations()
                    {
                        /* IN CLASS Doctrine_Relation_Parser (or child) */
                        
                        FOREACH ($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_pending as $alias =&amp;gt; $v) {
                            $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;getRelation($alias)
                            {
                                &lt;span class=&quot;code-comment&quot;&gt;//...
&lt;/span&gt;                                /*
                                 * In the &lt;span class=&quot;code-keyword&quot;&gt;case&lt;/span&gt; of an &lt;span class=&quot;code-quote&quot;&gt;&quot;association relation&quot;&lt;/span&gt; through a refTable:
                                 *   binds a *pending* (simple foreign key) relation to the refTable parser,
                                 *   binds a *pending* (simple foreign key) relation to itself,
                                 *   and &lt;span class=&quot;code-quote&quot;&gt;&quot;finalizes&quot;&lt;/span&gt; (adds to $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_relations) its association relation
                                 */
                            }
                        }
                    }
                    &lt;span class=&quot;code-comment&quot;&gt;//...
&lt;/span&gt;                }
            }
        }
    }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;So, with our example schema,&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;LinkTable is exported with &lt;b&gt;no&lt;/b&gt; constraints (because has no relations at this time);&lt;/li&gt;
	&lt;li&gt;Table1 gets parsed, which finalizes the pending relation with Table2 (binded when loaded), binds to itself a pending relation with LinkTable, and binds to LinkTable parser the first &lt;b&gt;pending&lt;/b&gt; relation (with Table1); Table1 is then exported whilst it still has a pending relation;&lt;/li&gt;
	&lt;li&gt;Table2 gets parsed and exported the same way.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;So now we have 2 problems:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;each table has been exported immediately after its parsing, i.e. in an &lt;em&gt;incomplete state&lt;/em&gt; (&lt;b&gt;this is the present issue&lt;/b&gt;)&lt;/li&gt;
	&lt;li&gt;even after the whole relations parsing loop, LinkTable has still &lt;em&gt;2 pending relations&lt;/em&gt;, and each of both other tables has one &quot;final&quot; &lt;em&gt;and one pending&lt;/em&gt; (but maybe it is supposed to be so...)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Note that a second call to Doctrine_Core::generateSqlFromModels() just after the first one, will parse all models one more time and thus finalize those pending relations, generating all constraints (also will subsequent calls).&lt;/p&gt;


&lt;p&gt;For now I don&apos;t have a fix but I think we could consider:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;loop twice in Doctrine_Export::exportSortedClassesSql() and exportClassesSql(), and construct SQL queries only the 2nd time (but... hum...)&lt;/li&gt;
	&lt;li&gt;improve Doctrine_Relation_Parser? maybe explicitly call getRelations() after each bind() (in the getRelation() function)...&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Anyway it seems clear that export shouldn&apos;t be done before all tables have been parsed.&lt;/p&gt;

&lt;p&gt;G.X&lt;/p&gt;</comment>
                    <comment id="13283" author="gx" created="Sat, 12 Jun 2010 16:17:25 +0000"  >&lt;p&gt;I still have no fix but in the waiting we can still discuss some &quot;user-side&quot; work-arounds (that don&apos;t need modifying Doctrine source code)...&lt;br/&gt;
Here is what crosses my mind first:&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;(in the PHP working code) do a first &quot;dummy&quot; call to 
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;$conn-&amp;gt;export-&amp;gt;exportClassesSql(Doctrine_Core::loadModels(&apos;models&apos;))&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt; just to ensure all relations are bound, then a &quot;real&quot; call to  &lt;tt&gt;Doctrine_Core::createTablesFromModels(&apos;models&apos;)&lt;/tt&gt; which will export all constraints well&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;(in the schema) rename &lt;em&gt;LinkTable&lt;/em&gt; to something like &lt;em&gt;ZzLinkTable&lt;/em&gt; so that it is exported last&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;&quot;explicitize&quot; the two (one-to-many) foreign key relations in LinkTable by completing the schema as follows:
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;schema.yml&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-none&quot;&gt;---
LinkTable:
  columns:
    table1_id:
      primary: true
      type:    integer
    table2_id:
      primary: true
      type:    integer
#(added)
  relations:
    Table1:
      local:   table1_id
      foreign: id
    Table2:
      local:   table2_id
      foreign: id
#(/added)
Table1:
  relations:
    Table2:
      refClass: LinkTable
      local:    table1_id
      foreign:  table2_id
Table2:
  relations:
    Table1:
      refClass: LinkTable
      local:    table2_id
      foreign:  table1_id
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(&lt;em&gt;I think this one would also &quot;solve&quot; the behavior problem of Papp Richard&lt;/em&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;But I&apos;m not that happy with the idea of choosing one of these &quot;hacks&quot; &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/sad.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; if I had to, I would use this last one but (unless you use some &quot;&lt;tt&gt;onDelete: CASCADE&lt;/tt&gt;&quot; or so) it looks like unnecessary duplication...&lt;br/&gt;
Someone, any other idea? ^^&lt;/p&gt;

&lt;p&gt;G.X&lt;/p&gt;

&lt;p&gt;(edit: typo fix)&lt;/p&gt;</comment>
                    <comment id="13292" author="gx" created="Sun, 13 Jun 2010 08:00:34 +0000"  >&lt;p&gt;We can try another approach too: let&apos;s say that our generated PHP models classes &lt;b&gt;are&lt;/b&gt; incomplete.&lt;/p&gt;

&lt;p&gt;Indeed, for a simple foreign key relation (i.e. o2o and o2m / m2o), we can define it only once on the owning side in the YAML file, and the schema importer will generate complete PHP classes, with the &quot;hasOne&quot; on the owning side &lt;b&gt;and&lt;/b&gt; the auto-completed &quot;hasMany&quot; on the opposite side. E.g:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;YAML schema&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-none&quot;&gt;Phonenumber:
  columns:
    user_id: integer
  relations:
    User: {local: user_id, foreign: id}
User:
# we don&apos;t precise the opposite relation here
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;will generate the following classes (simplified a bit):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;PHP models (1)&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-comment&quot;&gt;// models/Phonenumber.php
&lt;/span&gt;class Phonenumber &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition() {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;user_id&apos;, &apos;integer&apos;);
    }

    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp() {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasOne(&apos;User&apos;, array(&apos;local&apos;   =&amp;gt; &apos;user_id&apos;,
                                    &apos;foreign&apos; =&amp;gt; &apos;id&apos;));
    }
}

&lt;span class=&quot;code-comment&quot;&gt;// models/User.php
&lt;/span&gt;class User &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition() {
    }

    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp() {
        &lt;span class=&quot;code-comment&quot;&gt;// &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; was auto-added during the schema &lt;span class=&quot;code-keyword&quot;&gt;import&lt;/span&gt;:
&lt;/span&gt;        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasMany(&apos;Phonenumber&apos;, array(&apos;local&apos;   =&amp;gt; &apos;id&apos;,
                                            &apos;foreign&apos; =&amp;gt; &apos;user_id&apos;));
    }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;and this will work well.&lt;br/&gt;
BUT, now if we &lt;em&gt;remove the auto-added hasMany()&lt;/em&gt; in User.php, then run the following (which worked well before our manual modification):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;test.php&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;require_once &apos;bootstrap.php&apos;;

$user = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; User();
Doctrine_Core::dump($user-&amp;gt;Phonenumber);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;we get some &lt;tt&gt;Fatal error: Uncaught exception &apos;Doctrine_Record_UnknownPropertyException&apos; with message &apos;Unknown record property / related component &quot;Phonenumber&quot; on &quot;User&quot;&apos;&lt;/tt&gt;, which is supposed to occur. Indeed, how could Doctrine know that a User has a &quot;link&quot; with Phonenumber? It would be only possible by parsing the relations of all the (loaded) models first...&lt;/p&gt;

&lt;p&gt;So we can say that &lt;em&gt;YAML schema files can be incomplete &lt;b&gt;whereas&lt;/b&gt; PHP models classes MUST be COMPLETE.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, considering it is not to change, why not apply this &quot;principle&quot; to (m2m) association relations?&lt;br/&gt;
i.e., &lt;b&gt;Doctrine documentation could warn&lt;/b&gt; that, if you want to have all constraints properly exported (like in the present issue) and/or use relations from an association class (having &lt;tt&gt;$link&lt;/tt&gt; instance of &lt;tt&gt;LinkTable&lt;/tt&gt;, you want to use &lt;tt&gt;$link-&amp;gt;Table1&lt;/tt&gt;, not just &lt;tt&gt;$link-&amp;gt;table1_id&lt;/tt&gt;), then you MUST complete your PHP models with the FK relations, like this:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;PHP models (2)&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-comment&quot;&gt;// models/LinkTable.php
&lt;/span&gt;class LinkTable &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition() {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;table1_id&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(
                &apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;table2_id&apos;, &apos;integer&apos;, &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;, array(
                &apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;));
    }

    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp() {
        &lt;span class=&quot;code-comment&quot;&gt;// ADD:
&lt;/span&gt;        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasOne(&apos;Table1&apos;, array(&apos;local&apos;   =&amp;gt; &apos;table1_id&apos;,
                                      &apos;foreign&apos; =&amp;gt; &apos;id&apos;));
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasOne(&apos;Table2&apos;, array(&apos;local&apos;   =&amp;gt; &apos;table2_id&apos;,
                                      &apos;foreign&apos; =&amp;gt; &apos;id&apos;));
    }
}

&lt;span class=&quot;code-comment&quot;&gt;// models/Table1.php
&lt;/span&gt;class Table1 &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition() {
    }

    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp() {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasMany(&apos;Table2&apos;, array(&apos;refClass&apos; =&amp;gt; &apos;LinkTable&apos;,
                                       &apos;local&apos;    =&amp;gt; &apos;table1_id&apos;,
                                       &apos;foreign&apos;  =&amp;gt; &apos;table2_id&apos;));
        &lt;span class=&quot;code-comment&quot;&gt;// add too?:
&lt;/span&gt;        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasMany(&apos;LinkTable&apos;, array(&apos;local&apos;    =&amp;gt; &apos;id&apos;,
                                          &apos;foreign&apos;  =&amp;gt; &apos;table1_id&apos;));
    }
}

&lt;span class=&quot;code-comment&quot;&gt;// models/Table2.php
&lt;/span&gt;class Table2 &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_Record
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition() {
    }

    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp() {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasMany(&apos;Table1&apos;, array(&apos;refClass&apos; =&amp;gt; &apos;LinkTable&apos;,
                                       &apos;local&apos;    =&amp;gt; &apos;table2_id&apos;,
                                       &apos;foreign&apos;  =&amp;gt; &apos;table1_id&apos;));
        &lt;span class=&quot;code-comment&quot;&gt;// add too?:
&lt;/span&gt;        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasMany(&apos;LinkTable&apos;, array(&apos;local&apos;    =&amp;gt; &apos;id&apos;,
                                          &apos;foreign&apos;  =&amp;gt; &apos;table2_id&apos;));
    }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;After all, these additional relations are bound internally (if not already defined) when exporting tables to DB...&lt;/p&gt;

&lt;p&gt;We also said that the YAML can be incomplete, but for now the short schema.yml I took as an example in my first comment results in PHP classes &lt;em&gt;without&lt;/em&gt; those (2+1+1) adds.&lt;/p&gt;

&lt;p&gt;So to allow YAML to be incomplete even for m2m relations, &lt;em&gt;Doctrine_Import_Schema#_buildRelationships()&lt;/em&gt; would need some &quot;improvement&quot; so that it creates the many-to-one relation for each many-to-many relation (and the opposite one-to-many relation, on the association class side i.e. the owning side, would be auto-completed afterwards). However, a m2m relation is allowed to be defined on one single end, thus may be created one the other end only when _&lt;em&gt;autoCompleteOppositeRelations()&lt;/em&gt; is called, i.e. after _&lt;em&gt;buildRelationships()&lt;/em&gt; has looped over all the existing relations. So &lt;em&gt;Doctrine_Import_Schema#_autoCompleteOppositeRelations()&lt;/em&gt; would need the same kind of improvement...&lt;/p&gt;

&lt;p&gt;In fact I&apos;m not sure of what is a &quot;well defined&quot; model as soon as it uses refClass, the documentation sometimes uses contradictory examples...&lt;/p&gt;

&lt;p&gt;Sorry I was so verbose!&lt;br/&gt;
Thank you for developing Doctrine &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-835] Inconsistent record validation on a notnull foreign key when the local relation is set</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-835</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Doctrine_Validator_ForeignKeys_TestCase#testForeignKeyIsValidIfLocalRelationIsSet()&lt;/p&gt;

&lt;p&gt;This test passes fine as is. But it fails if I make the following change:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-none&quot;&gt;public function testForeignKeyIsValidIfLocalRelationIsSet()
{
    //$person = new TestPerson();
    $address = new TestAddress();
        
    //$address-&amp;gt;Person = $person;    
    $address-&amp;gt;Person-&amp;gt;first_name = &quot;John&quot;;
        
    $table = $address-&amp;gt;getTable();
    $errors = $table-&amp;gt;validateField(&apos;person_id&apos;, $address-&amp;gt;person_id, $address);
        
    $this-&amp;gt;assertEqual(0, $errors-&amp;gt;count());
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The only difference is that instead of explicitly assigning $address-&amp;gt;Person, I&apos;m letting it happen automatically when assigning the first name. What is it about the property chaining when creating the related record that screws up doctrine&apos;s internal reference tracking?&lt;/p&gt;</description>
                <environment></environment>
            <key id="11806">DC-835</key>
            <summary>Inconsistent record validation on a notnull foreign key when the local relation is set</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="adamthehutt">Adam Huttler</reporter>
                        <labels>
                    </labels>
                <created>Thu, 19 Aug 2010 22:33:14 +0000</created>
                <updated>Tue, 24 Aug 2010 22:14:20 +0000</updated>
                                    <version>1.2.1</version>
                                                <component>Record</component>
                <component>Relations</component>
                <component>Validators</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="14019" author="adamthehutt" created="Thu, 19 Aug 2010 23:20:35 +0000"  >&lt;p&gt;This is an existing test case for which I&apos;ve added two tests. The first one fails, while the second passes. The first one captures the issue I&apos;m experiencing.&lt;/p&gt;</comment>
                    <comment id="14062" author="adamthehutt" created="Tue, 24 Aug 2010 22:14:20 +0000"  >&lt;p&gt;This patch augments the test file with the new test and also makes a change to Doctrine_Related_LocalKey that causes the test to pass.&lt;/p&gt;

&lt;p&gt;Unfortunately, it causes another test to fail: 1072.&lt;/p&gt;

&lt;p&gt;I don&apos;t fully understand test 1072, but it appears to be testing closely related behavior (i.e. relation chaining).&lt;/p&gt;

&lt;p&gt;What do you think?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10748" name="dc-835-patch.txt" size="1601" author="adamthehutt" created="Tue, 24 Aug 2010 22:14:20 +0000" />
                    <attachment id="10746" name="ForeignKeysTestCase.php" size="2549" author="adamthehutt" created="Thu, 19 Aug 2010 23:20:35 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-797] Records containing a one-to-one relation are hydrated as dirty/modified</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-797</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Attached is a self-contained 80 line test. In the test, Foo has an one to one relation to Bar. There is a null value in the foreign key column (at least one Foo without a Bar). And the relation is being used via this DQL:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Doctrine_Query::create()&amp;#45;&amp;gt;from(&apos;Foo f&apos;)&amp;#45;&amp;gt;leftJoin(&apos;f.Bar b&apos;)-&amp;gt;execute();&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;At around line 254 of Doctrine_Hydrator_Graph/Graph.php, the hydrator sets the value of the relation column to Doctrine_Null if there is no related record:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;$prev&lt;span class=&quot;error&quot;&gt;&amp;#91;$parent&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;$relationAlias&amp;#93;&lt;/span&gt; = $this-&amp;gt;getNullPointer();&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;This causes Doctrine_Record to check if the value of the foreign key field was updated, which it does by calling Doctrine_Record::_isValueModified(). However, that method considers an update from null to Doctrine_Null as a modification. So, the record (and eventually the entire Collection returned) is marked as Doctrine_Record::STATE_DIRTY, even though it contains no modifications. This occurs during hydration, so the caller never sees the record as being clean.&lt;/p&gt;

&lt;p&gt;The workaround I&apos;m using is to subclass Doctrine_Record, and return false from _isValueModified() when moving from null to Doctrine_Null. But I think this could also be fixed in the hydrator.&lt;/p&gt;</description>
                <environment></environment>
            <key id="11680">DC-797</key>
            <summary>Records containing a one-to-one relation are hydrated as dirty/modified</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="dominic.scheirlinck">Dominic Scheirlinck</reporter>
                        <labels>
                    </labels>
                <created>Mon, 26 Jul 2010 02:26:49 +0000</created>
                <updated>Wed, 6 Jul 2011 19:31:56 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Record</component>
                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="14403" author="dominic.scheirlinck" created="Wed, 15 Sep 2010 21:39:12 +0000"  >&lt;p&gt;Patch is here: &lt;a href=&quot;http://github.com/doctrine/doctrine1/pull/7&quot; class=&quot;external-link&quot;&gt;http://github.com/doctrine/doctrine1/pull/7&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="14576" author="dominic.scheirlinck" created="Sun, 17 Oct 2010 17:25:36 +0000"  >&lt;p&gt;New pull request, done on a topic branch this time (and rebased to be much nicer)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/doctrine/doctrine1/pull/8&quot; class=&quot;external-link&quot;&gt;http://github.com/doctrine/doctrine1/pull/8&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="16122" author="derek" created="Wed, 6 Jul 2011 19:16:40 +0000"  >&lt;p&gt;Record.php.diff contains basically the patch Dominic attached but also makes sure that the internal property value is set regardless of whether the record is marked as dirty or not.  Some code will break when the internal property value is left &amp;lt;unset&amp;gt; instead of Doctrine_Null.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="11025" name="Record.php.diff" size="1762" author="derek" created="Wed, 6 Jul 2011 19:16:40 +0000" />
                    <attachment id="10708" name="test.php" size="1829" author="dominic.scheirlinck" created="Mon, 26 Jul 2010 02:26:49 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-774] Cannot fromArray a toArray with many to many records</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-774</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When working with a many to many record, if you &lt;tt&gt;toArray&lt;/tt&gt; then &lt;tt&gt;synchronizeWithArray&lt;/tt&gt;/&lt;tt&gt;fromArray&lt;/tt&gt; the result - you get an exception. &lt;/p&gt;

&lt;p&gt;This appears to be due to the fact that &lt;tt&gt;toArray&lt;/tt&gt; returns collections of &lt;tt&gt;array(0 =&amp;gt; false)&lt;/tt&gt; (because a record is in a locked state) and &lt;tt&gt;fromArray&lt;/tt&gt; will attempt to &lt;tt&gt;link()&lt;/tt&gt; the &lt;tt&gt;refClass&lt;/tt&gt; (which has multiple identifiers).&lt;/p&gt;

&lt;p&gt;Here&apos;s a test that should show this behavior: &lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;class Doctrine_Ticket_DC774_TestCase &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; Doctrine_UnitTestCase
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function prepareTables()
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;tables[] = &apos;EntityAddress&apos;;
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;tables[] = &apos;Book&apos;;
        parent::prepareTables();
    }

    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function prepareData()
    {
        $user = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; User();
        $user-&amp;gt;name = &apos;TestUser&apos;;

        $address = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Address();
        $address-&amp;gt;address = &apos;TestAddress&apos;;

        $user-&amp;gt;Addresses[] = $address;
        
        $user-&amp;gt;save();
    }

    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function testToArraySynchronizeWithManyToMany() {
        $user = Doctrine_Core::getTable(&apos;User&apos;)-&amp;gt;findOneByName(&apos;TestUser&apos;);
        $user-&amp;gt;refreshRelated();
        $user-&amp;gt;synchronizeWithArray($user-&amp;gt;toArray());
    }

    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function testToArrayFromManyToMany() {
        $user = Doctrine_Core::getTable(&apos;User&apos;)-&amp;gt;findOneByName(&apos;TestUser&apos;);
        $user-&amp;gt;refreshRelated();
        $user-&amp;gt;fromArray($user-&amp;gt;toArray());
    }
}

&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
            <key id="11578">DC-774</key>
            <summary>Cannot fromArray a toArray with many to many records</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="jochu">Jeff Chu</reporter>
                        <labels>
                    </labels>
                <created>Thu, 1 Jul 2010 19:00:14 +0000</created>
                <updated>Thu, 1 Jul 2010 20:04:35 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Record</component>
                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="13493" author="jochu" created="Thu, 1 Jul 2010 19:42:18 +0000"  >&lt;p&gt;I doubt this is the right way to fix this, but we wrote in a patch that has the link() function ignore relations that with multiple identifiers. I figured this would be alright since linking those in directly don&apos;t make too much sense anyways.&lt;/p&gt;

&lt;p&gt;It seems to pass the doctrine test suite. I&apos;ve attached the patch in case anyone is curious. &lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10687" name="doctrine-link.patch" size="1478" author="jochu" created="Thu, 1 Jul 2010 19:42:18 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-742] Add support for relations consist on two or more fileds</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-742</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Let&apos;s say I have following tables:&lt;/p&gt;

&lt;p&gt;article&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;art_id&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;article_version&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;art_id&lt;/li&gt;
	&lt;li&gt;art_version&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;category&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;cat_id&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;category2article&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;cat_id&lt;/li&gt;
	&lt;li&gt;art_id&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;category2article_version&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;cat_id&lt;/li&gt;
	&lt;li&gt;art_id&lt;/li&gt;
	&lt;li&gt;art_version&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;As I know I can describe relation between tables `article` and `category`, but I cannot describe relation between `artcile_version` and `category`.&lt;br/&gt;
The problem is Doctrine supports only following relation mapping:&lt;br/&gt;
$this-&amp;gt;hasMany(&apos;Category as categories&apos;, array(&lt;br/&gt;
    &apos;local&apos;    =&amp;gt; &apos;art_id&apos;,&lt;br/&gt;
    &apos;foreign&apos;  =&amp;gt; &apos;cat_id&apos;,&lt;br/&gt;
    &apos;refClass&apos; =&amp;gt; &apos;Category2Article&apos;&lt;br/&gt;
));&lt;/p&gt;

&lt;p&gt;It would be nice to have also something like that:&lt;br/&gt;
$this-&amp;gt;hasMany(&apos;Category as categories&apos;, array(&lt;br/&gt;
    &apos;local&apos;    =&amp;gt; array(&apos;art_id&apos;, &apos;art_version&apos;)&lt;br/&gt;
    &apos;foreign&apos;  =&amp;gt; &apos;cat_id&apos;,&lt;br/&gt;
    &apos;refClass&apos; =&amp;gt; &apos;Category2ArticleVc&apos;&lt;br/&gt;
));&lt;/p&gt;

&lt;p&gt;In the first (supported) example Doctrine produce something like that, when I add LEFT JOIN STATEMENT:&lt;br/&gt;
SELECT *&lt;br/&gt;
FROM article a&lt;br/&gt;
LEFT OUTER JOIN category2article c2a ON c2a.art_id = a.art_id&lt;br/&gt;
LEFT OUTER JOIN category c ON c.cat_id = c2a.cat_id&lt;/p&gt;

&lt;p&gt;But I would like to have also support for following example:&lt;br/&gt;
SELECT *&lt;br/&gt;
FROM article_version a_vc&lt;br/&gt;
LEFT OUTER JOIN category2article_version c2a_vc ON c2a_vc.art_id = a_vc.art_id AND c2a_vc.art_version = a_vc.art_version&lt;br/&gt;
LEFT OUTER JOIN category c ON c.cat_id = c2a_vc.cat_id&lt;/p&gt;

&lt;p&gt;&amp;#8211;&lt;br/&gt;
Very best,&lt;br/&gt;
Tomasz Kuter&lt;/p&gt;

&lt;p&gt;PS. I will check Doctrine code.. maybe I will solve it by myself..&lt;/p&gt;</description>
                <environment>n/a</environment>
            <key id="11507">DC-742</key>
            <summary>Add support for relations consist on two or more fileds</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="evolic">Tomasz Kuter</reporter>
                        <labels>
                    </labels>
                <created>Wed, 16 Jun 2010 10:55:27 +0000</created>
                <updated>Sat, 7 Aug 2010 15:40:14 +0000</updated>
                                                                    <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-891] [PATCH] Relation array as the result of Doctrine_Table::bind()</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-891</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;It would be handy to return a relation array as the result of Doctrine_Table::bind(), because the relation parser&apos;s bind() already returns this value.&lt;/p&gt;</description>
                <environment></environment>
            <key id="12012">DC-891</key>
            <summary>[PATCH] Relation array as the result of Doctrine_Table::bind()</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</type>
                                <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="romanb">Roman S. Borschel</assignee>
                                <reporter username="rybakit">Eugene Leonovich</reporter>
                        <labels>
                    </labels>
                <created>Mon, 18 Oct 2010 05:12:51 +0000</created>
                <updated>Mon, 18 Oct 2010 05:13:29 +0000</updated>
                                                                    <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                                <attachments>
                    <attachment id="10827" name="bind.patch" size="1161" author="rybakit" created="Mon, 18 Oct 2010 05:12:51 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-993] Many-to-many Relation defined one way </title>
                <link>http://www.doctrine-project.org/jira/browse/DC-993</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;When a many-tomany relation has been defined on only one of the end of the relation, and ofcourse in the cross-refClass, things get weird. I&apos;ll use the &lt;b&gt;user-groups&lt;/b&gt; relation (as found in the documentation) as example.&lt;/p&gt;

&lt;p&gt;If in the &lt;b&gt;group&lt;/b&gt; model has not defined the &lt;tt&gt;hasMany&lt;/tt&gt;, then a &lt;b&gt;user&lt;/b&gt; can be instantiated and saved. When instantiated, the relation &lt;em&gt;groups&lt;/em&gt; would return an empty array, groups can ben added like:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;$u = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; User();
var_dump($u-&amp;gt;groups);
$u-&amp;gt;groups[] = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Group();
var_dump($u-&amp;gt;groups);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;This would output an empty array, and subsequently an array containing the new group.&lt;/p&gt;

&lt;p&gt;However, if a &lt;b&gt;user&lt;/b&gt; would be retrieved from the database, and the relation &lt;em&gt;groups&lt;/em&gt; would be called, then the following message will appear (which is not helpfull at alllll, I&apos;ve spend hours figuring it out!):&lt;/p&gt;

&lt;p&gt;Uncaught exception &apos;Doctrine_Record_UnknownPropertyException&apos; with message &apos;Unknown record property / related component &quot;groups&quot;&apos; .....&lt;/p&gt;

&lt;p&gt;I will never forget this, but it&apos;s not described in the documentation and the error is not helping either. So either one of these step hvae to be taken. Or even better, making it work without requiring the &lt;tt&gt;hasMany&lt;/tt&gt; in &lt;b&gt;group&lt;/b&gt;, to &lt;em&gt;users&lt;/em&gt;.&lt;/p&gt;</description>
                <environment>MySQL database, Lenny</environment>
            <key id="12535">DC-993</key>
            <summary>Many-to-many Relation defined one way </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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="romanb">Roman S. Borschel</assignee>
                                <reporter username="kweij">Klaas van der Weij</reporter>
                        <labels>
                    </labels>
                <created>Tue, 5 Apr 2011 07:09:51 +0000</created>
                <updated>Tue, 5 Apr 2011 07:09:51 +0000</updated>
                                    <version>1.2.2</version>
                <version>1.2.3</version>
                <version>1.2.4</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-560] Object1-&gt;Unlink(Relation, Id2) doesn&apos;t work, if primary key order in table of m2m reference isnt 1:Object 2: Id to unlink, when relation set to EQUAL= TRUE</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-560</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Object1-&amp;gt;Unlink(Relation, Id2) doesn&apos;t work, if primary key order in table of m2m reference isnt 1:Object 2: Id to unlink, when relation set to EQUAL= TRUE&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;User:
  actAs: 
    Timestampable: ~
  columns:    
    name:         { type: string(255), notnull: &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt; }
    last_name:    { type: string(255), notnull: &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt; }
    picture:      { type: string(255), notnull: &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt; }
    birthday:     { type: timestamp, notnull: &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt; }
    gender:       { type: string(255) }
    rating:       { type: integer, &lt;span class=&quot;code-keyword&quot;&gt;default&lt;/span&gt;:0} 
    num_comments: { type: integer, &lt;span class=&quot;code-keyword&quot;&gt;default&lt;/span&gt;:0} 
    num_groups:   { type: integer, &lt;span class=&quot;code-keyword&quot;&gt;default&lt;/span&gt;:0} 
  inheritance:
    &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt;: Member
    type: column_aggregation
    keyField: type
    keyValue: 1                    
  relations:
    Friends:    { onDelete: CASCADE, class: User, foreignAlias: Friends, refClass: FriendReference, local: user1, foreign: user2, equal: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt; }
    Request:    { onDelete: CASCADE, class: User, foreignAlias: Pending, refClass: PendingReference, local: user1, foreign: user2 }
    Blocker:    { onDelete: CASCADE, class: User, foreignAlias: Blocked, refClass: BlockedReference, local: user1, foreign: user2 }

&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;




&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt; 
			&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;(isset($refToRemove))
			{
				&lt;span class=&quot;code-keyword&quot;&gt;switch&lt;/span&gt; ($refToRemove)
				{
					&lt;span class=&quot;code-keyword&quot;&gt;case&lt;/span&gt; &apos;FriendReference&apos;: $references = $currentUser-&amp;gt;Friends; $relation = &apos;Friends&apos;;	&lt;span class=&quot;code-keyword&quot;&gt;break&lt;/span&gt;;
					&lt;span class=&quot;code-keyword&quot;&gt;case&lt;/span&gt; &apos;PendingReference&apos;: $references = $currentUser-&amp;gt;Pending; $relation = &apos;Pending&apos;; &lt;span class=&quot;code-keyword&quot;&gt;break&lt;/span&gt;;
					&lt;span class=&quot;code-keyword&quot;&gt;case&lt;/span&gt; &apos;BlockerReference&apos;: $references = $currentUser-&amp;gt;Blocker; $relation = &apos;Blocker&apos;; &lt;span class=&quot;code-keyword&quot;&gt;break&lt;/span&gt;;
					&lt;span class=&quot;code-keyword&quot;&gt;case&lt;/span&gt; &apos;RequestReference&apos;: $references = $currentUser-&amp;gt;Request; $relation = &apos;Request&apos;; &lt;span class=&quot;code-keyword&quot;&gt;break&lt;/span&gt;;
				}
				 
				foreach($references as $reference)
				{

					&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($reference-&amp;gt;id == $user2-&amp;gt;id)
                        $currentUser-&amp;gt;unlink($relation, array($user2-&amp;gt;id), $now = &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;);
				}
                
			}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;when you count relations from one side and the other it show that when set to EQUAL = TRUE relations are reciprocal, but unlink still minds primary keys order in order to function&lt;/p&gt;</description>
                <environment>Windows XP, Apache 2.2, PHP 5, Doctrine 1.2 on Symfony 1.4</environment>
            <key id="11021">DC-560</key>
            <summary>Object1-&gt;Unlink(Relation, Id2) doesn&apos;t work, if primary key order in table of m2m reference isnt 1:Object 2: Id to unlink, when relation set to EQUAL= TRUE</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="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/reopened.png">Reopened</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="marciano">Mariano Ramon</reporter>
                        <labels>
                    </labels>
                <created>Wed, 10 Mar 2010 12:11:56 +0000</created>
                <updated>Thu, 27 Jan 2011 13:26:33 +0000</updated>
                                    <version>1.2.0</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="12227" author="jwage" created="Mon, 15 Mar 2010 16:04:44 +0000"  >&lt;p&gt;I am unable to reproduce the issue. When I test everything works as expected. We really need some more information and a test case in order to be sure of any issue.&lt;/p&gt;</comment>
                    <comment id="12522" author="slickrick" created="Tue, 30 Mar 2010 17:11:04 +0000"  >&lt;p&gt;I was able to reproduce this issue in Doctrine 1.2. The issue is a two part scenerio, which makes it kind of hard to debug.   But here is how to reproduce it.&lt;/p&gt;

&lt;p&gt;1.) Lets assume you have a Product model with ID 14.  &lt;br/&gt;
2.) Lets assume you have an &quot;equal&quot; M:M table that links to itself, (product_product_group). &quot;product_id_1&quot; and &quot;product_id_2&quot; are a compound primary key which link back to the Product model.&lt;br/&gt;
3.) Lets assume you that Product 14 is currently linked to products with IDs 2, 5, and 13.&lt;br/&gt;
4.) Assuming $object is an instance of Product id 14, call $object-&amp;gt;unlink(array(2));&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;SQL QUERY LOG for Step 4.)&lt;br/&gt;
482 Query       START TRANSACTION&lt;br/&gt;
482 Query       DELETE FROM product_product_group WHERE (product_id_1 = &apos;14&apos; AND product_id_2 IN (&apos;2&apos;))&lt;br/&gt;
482 Query       UPDATE product_product_group SET product_id_1 = &apos;5&apos; WHERE product_id_1 = &apos;14&apos; AND product_id_2 = &apos;5&apos;&lt;br/&gt;
482 Query       UPDATE product_product_group SET product_id_1 = &apos;13&apos; WHERE product_id_1 = &apos;14&apos; AND product_id_2 = &apos;13&apos;&lt;br/&gt;
482 Query       DELETE FROM product_product_group WHERE product_id_2 = &apos;2&apos; AND product_id_1 = &apos;14&apos;&lt;br/&gt;
482 Query       COMMIT&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;The result is as follows:&lt;br/&gt;
  a.) Doctrine properly unlinks ID 2&lt;br/&gt;
  b.) Doctrine updates the M:M table and sets the remaining two IDs (5 and 13) and links them to themselves (it shouldn&apos;t run these updates).  Now, all we have in our database are two links (5-5 and 13-13).&lt;/p&gt;

&lt;p&gt;5.) Now, Product ID 14 has no links anymore in the M:M table.  So we call $object-&amp;gt;link(array(2, 5, 13));  &lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;SQL QUERY LOG for Step 5.)&lt;br/&gt;
512 Query       START TRANSACTION&lt;br/&gt;
512 Query       SELECT ... FROM to_product_id t WHERE (t.id IN (&apos;13&apos;, &apos;2&apos;, &apos;5&apos;))&lt;br/&gt;
512 Query       INSERT INTO to_product_id_to_product_id_group (product_id_2, product_id_1) VALUES (&apos;2&apos;, &apos;14&apos;)&lt;br/&gt;
512 Query       INSERT INTO to_product_id_to_product_id_group (product_id_2, product_id_1) VALUES (&apos;5&apos;, &apos;14&apos;)&lt;br/&gt;
512 Query       INSERT INTO to_product_id_to_product_id_group (product_id_2, product_id_1) VALUES (&apos;13&apos;, &apos;14&apos;)&lt;br/&gt;
512 Query       COMMIT&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;This works as expected.&lt;/p&gt;

&lt;p&gt;6.) Now, in our database, Product ID 14 properly links to Ids 2, 5, and 13. BUT IDs 5 and 13 also have a link to themselves as a byproduct of the UPDATE queries called in step 4.).&lt;br/&gt;
7.) Now, we call $object-&amp;gt;unlink(array(2)) again.&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;SQL QUERY LOG for Step 7.)&lt;br/&gt;
432 Query       START TRANSACTION&lt;br/&gt;
432 Query       DELETE FROM product_product_group WHERE (product_id_1 = &apos;14&apos; AND product_id_2 IN (&apos;2&apos;))&lt;br/&gt;
432 Query       UPDATE product_product_group SET product_id_1 = &apos;5&apos; WHERE product_id_1 = &apos;2&apos; AND product_id_2 = &apos;5&apos;&lt;br/&gt;
432 Query       UPDATE product_product_group SET product_id_1 = &apos;5&apos; WHERE product_id_1 = &apos;14&apos; AND product_id_2 = &apos;5&apos;&lt;br/&gt;
432 Query       ROLLBACK&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;The following error occurs:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Mar 30 20:40:41 symfony &lt;span class=&quot;error&quot;&gt;&amp;#91;err&amp;#93;&lt;/span&gt; exception &apos;Doctrine_Connection_Mysql_Exception&apos; with message &apos;SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;23000&amp;#93;&lt;/span&gt;: Integrity constraint violation: 1062 Duplicate entry &apos;5-5&apos; for key 1&apos; in /path/to/symfony/1.4/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php:1082&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;So basically, it repeated the same queries from step 4.), however this time around, when attempting to set ID 5 to itself, it fails because there is already an entry this pair in the database.  Since we have a compound primary key, this non-unique combination is not allowed.  I don&apos;t know why its trying to run these UPDATE queries, but its definitely something to do with thre relationship being &quot;equal&quot;.&lt;/p&gt;</comment>
                    <comment id="13189" author="jwage" created="Tue, 8 Jun 2010 14:37:14 +0000"  >&lt;p&gt;It is hard to decipher the problem. It is best and most clear to provide a test case.&lt;/p&gt;</comment>
                    <comment id="15195" author="slickrick" created="Thu, 27 Jan 2011 13:26:33 +0000"  >&lt;p&gt;I know this is old, and is likely to never be resolved, but the problem does still exist.&lt;/p&gt;

&lt;p&gt;Basically, &quot;unlinking&quot; an equal relation only unlinks one side of the relationship:&lt;/p&gt;

&lt;p&gt;DELETE FROM user_user_group WHERE (user_id_1 = &apos;20&apos; AND user_id_2 IN (&apos;9&apos;))&lt;/p&gt;

&lt;p&gt;However, if the relationship was created from the other side (i.e. user_id_1 = 9 and user_id_2 = 20), then it doesn&apos;t properly get rid of the relationship.  Again, this only applies when a relationship is marked as &quot;equal&quot;.&lt;/p&gt;

&lt;p&gt;Here is another post about the same issue, with their work-around:&lt;br/&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/1385281/how-do-i-remove-a-self-referencing-nn-relation-in-doctrine&quot; class=&quot;external-link&quot;&gt;http://stackoverflow.com/questions/1385281/how-do-i-remove-a-self-referencing-nn-relation-in-doctrine&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-776] $record-&gt;link(&apos;Alias&apos;, $id) throws an exception because of getIdentifier returns array, not string</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-776</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I want to bookmark ads on my site. So i have Ads table, users table (sfDoctrineGuard) and a refclass Bookmarks. I&apos;ve created an ajax link to an action, where i retrieved $ad object, $user_id and &lt;br/&gt;
$ad-&amp;gt;link(&apos;Bookmarks&apos;, $user_id, true);&lt;br/&gt;
So I expected a record in a database to be created. &lt;/p&gt;

&lt;p&gt;Bookmarks:&lt;br/&gt;
...&lt;br/&gt;
  columns:&lt;br/&gt;
    user_id: &lt;/p&gt;
{ type: integer(4), primary: true }
&lt;p&gt;    ad_id:  &lt;/p&gt;
{ type: integer(4), primary: true }
&lt;p&gt;  relations:&lt;br/&gt;
    sfGuardUser: &lt;/p&gt;
{ onDelete: CASCADE, local: user_id, foreign: id }
&lt;p&gt;    Ads: &lt;/p&gt;
{ onDelete: CASCADE, local: ad_id,  foreign: ad_id }

&lt;p&gt;As my Bookmarks table has 2 primary keys in the link method &lt;/p&gt;

&lt;p&gt;            if (count($ids) &amp;gt; 0) &lt;/p&gt;
{
                $q-&amp;gt;whereIn($rel-&amp;gt;getTable()-&amp;gt;getIdentifier(), array_values($this-&amp;gt;identifier()));
            }

&lt;p&gt;$rel-&amp;gt;getTable()-&amp;gt;getIdentifier() returned me an array(&apos;user_id&apos;, &apos;ad_id&apos;) instead of a string. So the query which was generated looked like&lt;br/&gt;
UPDATE bookmarks SET ad_id = ? WHERE (Array IN &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/help_16.gif&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;)&lt;br/&gt;
And Array is not the name of a column.&lt;/p&gt;

&lt;p&gt;My schema:&lt;br/&gt;
&lt;a href=&quot;http://pastie.org/private/2lr9gy1h3mtdwdsiwrwylq&quot; class=&quot;external-link&quot;&gt;http://pastie.org/private/2lr9gy1h3mtdwdsiwrwylq&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I&apos;ve solved an issue by creating a new Bookmark instance and saving it, but i presume that issue might distract someone.&lt;/p&gt;</description>
                <environment>Symfony 1.4.6-DEV</environment>
            <key id="11588">DC-776</key>
            <summary>$record-&gt;link(&apos;Alias&apos;, $id) throws an exception because of getIdentifier returns array, not string</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="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="charnad">Viktoras Bezaras</reporter>
                        <labels>
                    </labels>
                <created>Mon, 5 Jul 2010 18:01:58 +0000</created>
                <updated>Mon, 5 Jul 2010 18:05:14 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Record</component>
                <component>Relations</component>
                <component>Schema Files</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                </attachments>
            <subtasks>
            <subtask id="11587">DC-775</subtask>
        </subtasks>
        </item>

<item>
            <title>[DC-1032] [PATCH] Doctrine_Collection::isModified() does not support deep like Doctrine_Record but probably should</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-1032</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;$record instanceof Doctrine_Record;&lt;br/&gt;
$collection instanceof Doctrine_Collection;&lt;/p&gt;

&lt;p&gt;Using the $record object I can find out if it has been modified : $record-&amp;gt;isModified().&lt;br/&gt;
I can also have this check all the relations also by passing true : $record-&amp;gt;isModified(true);&lt;/p&gt;

&lt;p&gt;However, the $collection object only support the first level and not the relations of its member records,&lt;br/&gt;
$collection-&amp;gt;isModified() returns false if one of the entry has one its relations modified (as it should).&lt;/p&gt;

&lt;p&gt;The improvement would be to allow this method to accept true, like it&apos;s $record counterpart, which would return true instead.&lt;/p&gt;

&lt;p&gt;See attached patch.&lt;/p&gt;</description>
                <environment></environment>
            <key id="12963">DC-1032</key>
            <summary>[PATCH] Doctrine_Collection::isModified() does not support deep like Doctrine_Record but probably should</summary>
                <type id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/improvement.png">Improvement</type>
                                <priority id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/trivial.png">Trivial</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="romanb">Roman S. Borschel</assignee>
                                <reporter username="roychri">Christian Roy</reporter>
                        <labels>
                    </labels>
                <created>Tue, 23 Aug 2011 18:05:04 +0000</created>
                <updated>Tue, 23 Aug 2011 18:24:25 +0000</updated>
                                    <version>1.2.3</version>
                <version>1.2.4</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                                <attachments>
                    <attachment id="11058" name="DC-1032.patch" size="865" author="roychri" created="Tue, 23 Aug 2011 18:05:04 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-730] &quot;// ?? should this not be $this-&gt;_table-&gt;getComponentName() ??&quot; in Doctrine/Relation/Parser.php</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-730</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;In class Doctrine_Relation_Parser, in method completeDefinition(), at line 508 (for svn r.7676) there is the code:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;php&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-none&quot;&gt;&#160;               foreach ((array) $this-&amp;gt;_table-&amp;gt;getIdentifierColumnNames() as $id) {
                    // ?? should this not be $this-&amp;gt;_table-&amp;gt;getComponentName() ??
                    $column = strtolower($table-&amp;gt;getComponentName())
                            . &apos;_&apos; . $id;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The comment on line 509 seems right, since &lt;em&gt;$table&lt;/em&gt; is a &quot;temporary&quot; variable created in a previous &lt;em&gt;foreach&lt;/em&gt; loop a few lines before (l. 472) and not used anywhere else... (I didn&apos;t make a test case though, that&apos;s why I tagged it as &quot;Task&quot; rather than &quot;Bug&quot;)&lt;/p&gt;

&lt;p&gt;I attached a patch, just in case.&lt;/p&gt;

&lt;p&gt;G.X&lt;/p&gt;</description>
                <environment>doctrine1 svn 1.2 rev. 7676</environment>
            <key id="11479">DC-730</key>
            <summary>&quot;// ?? should this not be $this-&gt;_table-&gt;getComponentName() ??&quot; in Doctrine/Relation/Parser.php</summary>
                <type id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/task.png">Task</type>
                                <priority id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/trivial.png">Trivial</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="romanb">Roman S. Borschel</assignee>
                                <reporter username="gx">Guilliam X</reporter>
                        <labels>
                    </labels>
                <created>Sat, 12 Jun 2010 10:33:21 +0000</created>
                <updated>Wed, 16 Jun 2010 06:07:16 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Relations</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="13324" author="gx" created="Tue, 15 Jun 2010 06:46:47 +0000"  >&lt;p&gt;Edited the patch with &quot;branches/1.2&quot; as root&lt;/p&gt;

&lt;p&gt;I can&apos;t provide a test case but they all run without failure after patching &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                    <comment id="13333" author="gx" created="Wed, 16 Jun 2010 06:07:16 +0000"  >&lt;p&gt;Converted patch to Unix-like EOL style (was made on Windows...)&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10656" name="DC-730.patch" size="760" author="gx" created="Wed, 16 Jun 2010 06:07:16 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>