<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Wed Jun 19 05:49:24 UTC 2013

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

<item>
            <title>[DBAL-211] wrong where clause in PostgreSqlPlatform::getTableWhereClause</title>
                <link>http://www.doctrine-project.org/jira/browse/DBAL-211</link>
                <project id="10040" key="DBAL">Doctrine DBAL</project>
                        <description>&lt;p&gt;I have the folowing table structure:&lt;/p&gt;

&lt;p&gt;Schema &quot;public&quot;:  with one table called &quot;users&quot;&lt;br/&gt;
Schema &quot;forums&quot;: with one table called &quot;users&quot; &lt;/p&gt;


&lt;p&gt;methods like &lt;tt&gt;PostgreSqlPlatform::getListTableForeignKeysSQL($table, $database = &apos;&apos;)&lt;/tt&gt; should list FK inside &lt;tt&gt;$table&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;the default search path is &quot;public,pg_catalog&quot;&lt;/p&gt;


&lt;p&gt;calling &lt;tt&gt;PostgreSqlPlatform::getListTableForeignKeysSQL(&apos;users&apos;)&lt;/tt&gt; it shuld extract the FK from &lt;tt&gt;public.users&lt;/tt&gt; table, but this is the current result:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;PDOException&amp;#93;&lt;/span&gt; SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;21000&amp;#93;&lt;/span&gt;: Cardinality violation: 7 ERROR:  more than one row returned by a subquery used as an expression&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;this exception is thrown because &lt;tt&gt;PostgreSqlPlatform::getTableWhereClause&lt;/tt&gt; do not cosider the current search path.&lt;/p&gt;

&lt;p&gt;i propose the following implementation for &lt;tt&gt;PostgreSqlPlatform::getTableWhereClause&lt;/tt&gt;&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;private&lt;/span&gt; function getTableWhereClause($table, $classAlias = &apos;c&apos;, $namespaceAlias = &apos;n&apos;)
    {
        $whereClause = $namespaceAlias.&lt;span class=&quot;code-quote&quot;&gt;&quot;.nspname NOT IN (&apos;pg_catalog&apos;, &apos;information_schema&apos;, &apos;pg_toast&apos;) AND &quot;&lt;/span&gt;;
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (strpos($table, &lt;span class=&quot;code-quote&quot;&gt;&quot;.&quot;&lt;/span&gt;) !== &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;) {
            list($schema, $table) = explode(&lt;span class=&quot;code-quote&quot;&gt;&quot;.&quot;&lt;/span&gt;, $table);
            $whereClause .= &lt;span class=&quot;code-quote&quot;&gt;&quot;$classAlias.relname = &apos;&quot;&lt;/span&gt; . $table . &lt;span class=&quot;code-quote&quot;&gt;&quot;&apos; AND $namespaceAlias.nspname = &apos;&quot;&lt;/span&gt; . $schema . &lt;span class=&quot;code-quote&quot;&gt;&quot;&apos;&quot;&lt;/span&gt;;
        } &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt; {
            &lt;span class=&quot;code-comment&quot;&gt;// $whereClause .= &lt;span class=&quot;code-quote&quot;&gt;&quot;$classAlias.relname = &apos;&quot;&lt;/span&gt; . $table . &lt;span class=&quot;code-quote&quot;&gt;&quot;&apos;&quot;&lt;/span&gt;; // &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; was the current implementation
&lt;/span&gt;            $whereClause .= &lt;span class=&quot;code-quote&quot;&gt;&quot;$classAlias.relname = &apos;&quot;&lt;/span&gt; . $table . &lt;span class=&quot;code-quote&quot;&gt;&quot;&apos; AND $namespaceAlias.nspname = ANY(string_to_array((select setting from pg_catalog.pg_settings where name = &apos;search_path&apos;),&apos;,&apos;))&quot;&lt;/span&gt;;
        }

        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $whereClause;
    }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;this implementation will restrict the search range only to current &quot;search_path&quot;.&lt;/p&gt;


&lt;p&gt;(sorry for my english)&lt;/p&gt;</description>
                <environment>ubuntu + postgres</environment>
            <key id="13392">DBAL-211</key>
            <summary>wrong where clause in PostgreSqlPlatform::getTableWhereClause</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="1">Fixed</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="goetas">Asmir Mustafic</reporter>
                        <labels>
                    </labels>
                <created>Thu, 26 Jan 2012 08:40:33 +0000</created>
                <updated>Sat, 28 Jan 2012 09:55:23 +0000</updated>
                    <resolved>Sat, 28 Jan 2012 09:55:23 +0000</resolved>
                                            <fixVersion>2.1.6</fixVersion>
                <fixVersion>2.2</fixVersion>
                                <component>Platforms</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="17342" author="beberlei" created="Sat, 28 Jan 2012 09:39:07 +0000"  >&lt;p&gt;This looks very good.&lt;/p&gt;</comment>
                    <comment id="17343" author="beberlei" created="Sat, 28 Jan 2012 09:55:23 +0000"  >&lt;p&gt;Fixed&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>