Doctrine Projecthttp://www.doctrine-project.org/jira
This file is an XML representation of an issueen-us6.2.3626015-04-2014[DDC-2229] Undefined methodhttp://www.doctrine-project.org/jira/browse/DDC-2229
Doctrine 2 - ORM<p>There is an undefined method called in Doctrine\ORM\Query\SqlWalker</p>
<p>Fatal error: Call to undefined method Doctrine\ORM\Query\AST\PathExpression::isSimpleArithmeticExpression() in vendor\doctrine\orm\lib\Doctrine\ORM\Query\SqlWalker.php on line 2091</p>DDC-2229Undefined methodBugBlockerResolvedInvalidBenjamin EberleiKarma Dordrak (Drak)Wed, 9 Jan 2013 14:55:56 +0000Mon, 22 Apr 2013 11:17:53 +0000Mon, 8 Apr 2013 20:26:25 +00002.3ORM06<p>Hi Karma</p>
<p>Could you provide the failing DQL ?</p>
<p>Cheers</p><p>It's generating SQL from a Doctrine Collection in a proxy class. Here is a link to the example: <a href="https://github.com/zikula/core/pull/674#discussion_r2696186" class="external-link" rel="nofollow">https://github.com/zikula/core/pull/674#discussion_r2696186</a></p>
<p>The SQL being generated is </p>
<p> `SELECT t0.name AS name1, t0.value AS value2, t0.user_id AS user_id3 FROM users_attributes t0 WHERE t0.user_id = ?`</p>
<p>The ? should be the value 2, but for some reason it's not being added. I've checked the files in the stack-trace below and the right values are entering into the process, just the wrong SQL seems to be generated.</p>
<p>Exception Trace<br/>
#0 Exception thrown in C:\xampp\htdocs\core13\src\vendor\doctrine\dbal\lib\Doctrine\DBAL\DBALException.php, line 47.<br/>
#1 C:\xampp\htdocs\core13\src\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\BasicEntityPersister.php(1599): Doctrine\DBAL\Connection-&gt;executeQuery('SELECT t0.name ...', Array, Array)<br/>
#2 C:\xampp\htdocs\core13\src\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\BasicEntityPersister.php(1558): Doctrine\ORM\Persisters\BasicEntityPersister-&gt;getOneToManyStatement(Array, Object(Users\Entity\User))<br/>
#3 C:\xampp\htdocs\core13\src\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(2673): Doctrine\ORM\Persisters\BasicEntityPersister-&gt;loadOneToManyCollection(Array, Object(Users\Entity\User), Object(Doctrine\ORM\PersistentCollection))<br/>
#4 C:\xampp\htdocs\core13\src\vendor\doctrine\orm\lib\Doctrine\ORM\PersistentCollection.php(224): Doctrine\ORM\UnitOfWork-&gt;loadCollection(Object(Doctrine\ORM\PersistentCollection))<br/>
#5 C:\xampp\htdocs\core13\src\vendor\doctrine\orm\lib\Doctrine\ORM\PersistentCollection.php(576): Doctrine\ORM\PersistentCollection-&gt;initialize()<br/>
#6 C:\xampp\htdocs\core13\src\lib\util\UserUtil.php(1152): Doctrine\ORM\PersistentCollection-&gt;getIterator()<br/>
#7 C:\xampp\htdocs\core13\src\lib\util\UserUtil.php(2007): UserUtil::getVars('admin', false, 'uname', false)</p><p>Hi Drak,</p>
<p>Could you try to write a failing test case please ?</p>
<p>Cheers</p><p>ping! <img class="emoticon" src="http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif" height="16" width="16" align="absmiddle" alt="" border="0"/></p><p><tt>SqlWalker::walkInExpression()</tt> does this:</p>
<p><tt>$sql = $this-&gt;walkArithmeticExpression($inExpr-&gt;expression)</tt></p>
<p>However, <tt>$inExpr-&gt;expression</tt> could be an instance of <tt>PathExpression</tt>. The grammar allows this case:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-sql">InExpression ::= SingleValuedPathExpression [<span class="code-quote">"NOT"</span>] <span class="code-quote">"IN"</span> <span class="code-quote">"("</span> (InParameter {<span class="code-quote">","</span> InParameter}* | Subselect) <span class="code-quote">")"</span></pre>
</div></div>
<p><tt>PathExpression</tt> and <tt>ArithmeticExpression</tt> both extend <tt>Node</tt>, but a <tt>PathExpression</tt> is not an <tt>ArithmeticExpression</tt>, and therefore it has no method <tt>isSimpleArithmeticExpression</tt>.</p>
<p>If you still need a failing test case, I'll write one when I get home from work.</p><p>Please Daniel Huss, A test case will be very useful..</p><p>failing test case</p><p>Bug still present in release 2.3.3</p>
<p>Is someone taking care of this? It seems easy enough to fix.</p><p><a href="http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=hussdl" class="user-hover" rel="hussdl">Daniel Huss</a> you can open a PR with the attached patch + test. Can you do it or should I take care of it?</p><p>Please take care of it for me this time. I'd rather avoid the git setup until I have a significant contribution to make.</p><p>This is invalid, you need to set the path expression differently, this is pseudo code:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">new</span> ArtihmeticExpression(<span class="code-keyword">new</span> SimpleArithmeticExpression(arithmeticsTerms =&gt; <span class="code-keyword">new</span> PathExpression)));
</pre>
</div></div><p>Could this be bug in the DQL grammar, then? If I'm not mistaken, the resolution of an InExpression cannot involve an ArithmeticPrimary non-terminal. I find the correct solution as shown by Benjamin Eberlei to be quite astonishing, since a path expression like "alias.field" is not something I'd associate with the term "arithmetic".</p>