<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Fri May 24 08:43:43 UTC 2013

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

<item>
            <title>[DDC-1435] Exception thrown when generating SQL from a DQL subselect where the entity has a foreign key as a primary key</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1435</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;If an entity has a foreign key as part of its primary key and you try to query that entity in a subselect clause in DQL, an exception is thrown in ClassMetadataInfo-&amp;gt;getQuotedColumnName. The problem seems to be that it&apos;s only considering the field mappings rather than both the field and association mappings when it&apos;s looking for the correct column name. &lt;/p&gt;

&lt;p&gt;Example entities:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Article(id primary key, title, content)&lt;/li&gt;
	&lt;li&gt;ArticleTag(article_id, tag, primary key (article_id, tag))&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Example DQL: select art from Article art where exists (select tag from ArticleTag tag where tag.article = art)&lt;/p&gt;
</description>
                <environment></environment>
            <key id="13100">DDC-1435</key>
            <summary>Exception thrown when generating SQL from a DQL subselect where the entity has a foreign key as a primary key</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="1">Fixed</resolution>
                    <security id="10000">All</security>
                        <assignee username="guilhermeblanco">Guilherme Blanco</assignee>
                                <reporter username="phekmat">Payam Hekmat</reporter>
                        <labels>
                    </labels>
                <created>Tue, 18 Oct 2011 17:47:05 +0000</created>
                <updated>Thu, 7 Jun 2012 08:39:52 +0000</updated>
                    <resolved>Sat, 29 Oct 2011 04:04:12 +0000</resolved>
                            <version>Git Master</version>
                                <fixVersion>2.1.3</fixVersion>
                                <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="16709" author="beberlei" created="Fri, 28 Oct 2011 06:21:21 +0000"  >&lt;p&gt;Verified:&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;    /**
     * @group DDC-1435
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function testForeignKeyAsPrimaryKeySubselect()
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;assertSqlGeneration(
            &lt;span class=&quot;code-quote&quot;&gt;&quot;SELECT s FROM Doctrine\Tests\Models\DDC117\DDC117Article s WHERE EXISTS (SELECT r FROM Doctrine\Tests\Models\DDC117\DDC117Reference r WHERE r.source = s)&quot;&lt;/span&gt;,
            &quot;&quot;
        );
    }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This however is not possible anyways, since you cannot have &quot;r&quot; in a SimpleSelectExpression when it resolves to multiple columns. You can try to select just one arbitrary field, for example.&quot;SELECT r.foobar FROM ..&quot;&lt;/p&gt;</comment>
                    <comment id="16712" author="phekmat" created="Fri, 28 Oct 2011 15:12:08 +0000"  >&lt;p&gt;Would that just be a documentation issue then? I didn&apos;t see that restriction in the &lt;a href=&quot;http://www.doctrine-project.org/docs/orm/2.1/en/reference/dql-doctrine-query-language.html#ebnf&quot; class=&quot;external-link&quot;&gt;grammar&lt;/a&gt;, but I may have overlooked it. I issued a &lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/159&quot; class=&quot;external-link&quot;&gt;pull request&lt;/a&gt; for this issue assuming that an association mapped field is valid input for getQuotedColumnName. &lt;/p&gt;

&lt;p&gt;Selecting a single field does work fine.&lt;/p&gt;</comment>
                    <comment id="16715" author="beberlei" created="Fri, 28 Oct 2011 22:37:13 +0000"  >&lt;p&gt;Did you touch this in your latest changes to SimpleSelectExpression guilherme?&lt;/p&gt;</comment>
                    <comment id="16718" author="guilhermeblanco" created="Sat, 29 Oct 2011 04:04:12 +0000"  >&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;@beberlei No. Issue was totally unrelated.&lt;br/&gt;
Please merge my commit to 2.1.X.&lt;/p&gt;

&lt;p&gt;The issue was caused by the identifier iteration was considering that @Id fields are always fields, never associations. You may see that in method getQuoteColumnName.&lt;/p&gt;

&lt;p&gt;Solution was to create a new method called getQuotedIdenitiferColumnNames and consume it in SqlWalker.&lt;br/&gt;
This addresses the issue.&lt;/p&gt;

&lt;p&gt;Committed patch and test case as of: &lt;a href=&quot;https://github.com/doctrine/doctrine2/commit/0ec2cc557f51d6240396689e36101f62d84d2a38&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/commit/0ec2cc557f51d6240396689e36101f62d84d2a38&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cheers,&lt;/p&gt;</comment>
                    <comment id="16722" author="beberlei" created="Sat, 29 Oct 2011 10:09:22 +0000"  >&lt;p&gt;Merged into 2.1.x&lt;/p&gt;</comment>
                    <comment id="16781" author="beberlei" created="Tue, 8 Nov 2011 23:49:05 +0000"  >&lt;p&gt;This issue is referenced in Github Pull-Request GH-159&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/159&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/159&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="18047" author="beberlei" created="Thu, 7 Jun 2012 08:39:52 +0000"  >&lt;p&gt;A related Github Pull-Request &lt;span class=&quot;error&quot;&gt;&amp;#91;GH-159&amp;#93;&lt;/span&gt; was opened&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/dbal/pull/159&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/dbal/pull/159&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>