<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>A.J. Brown&#039;s Blog &#187; Doctrine_Query</title> <atom:link href="http://ajbrown.org/blog/tags/doctrine_query/feed" rel="self" type="application/rss+xml" /><link>http://ajbrown.org/blog</link> <description>Coding adventures and technology musing for the masses</description> <lastBuildDate>Fri, 26 Mar 2010 17:57:50 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>New Doctrine Patch: BETWEEN relation alias parsing</title><link>http://ajbrown.org/blog/2008/12/30/new-doctrine-patch-between-relation-alias-parsing.html</link> <comments>http://ajbrown.org/blog/2008/12/30/new-doctrine-patch-between-relation-alias-parsing.html#comments</comments> <pubDate>Tue, 30 Dec 2008 21:44:30 +0000</pubDate> <dc:creator>A.J. Brown</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Doctrine ORM]]></category> <category><![CDATA[Doctrine_Query]]></category> <category><![CDATA[Doctrine_Query_Where]]></category><guid isPermaLink="false">http://ajbrown.org/blog/?p=151</guid> <description><![CDATA[Issue BETWEEN clauses with relational alias operands do not parse, resulting in an exception "could not find short alias". Example The following code will throw an exception. User hasOne Subscription. 1 2 3 $q1 = Doctrine_Query::create&#40;&#41; -&#62;select&#40;'u.id'&#41; -&#62;from&#40;'User u'&#41; -&#62;where&#40;&#34;CURRENT_DATE() BETWEEN u.Subscription.begin AND u.Subscription.end&#34;&#41; -&#62;addWhere&#40; 'u.id != 5' &#41;; Since the between operands are relational [...]]]></description> <content:encoded><![CDATA[<h4 id="toc-issue">Issue</h4><p>BETWEEN clauses with relational alias operands do not parse, resulting in an exception "could not find short alias".</p><h4 id="toc-example">Example</h4><p>The following code will throw an exception.  User hasOne Subscription.</p><div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$q1</span> <span style="color: #339933;">=</span> Doctrine_Query<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'u.id'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'User u'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;CURRENT_DATE() BETWEEN u.Subscription.begin AND u.Subscription.end&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addWhere</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'u.id != 5'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Since the between operands are relational aliases, and not literals or short aliases, Doctrine does not attempt to parse correctly.  I modified the behavior to do extra parsing on the expressions when BETWEEN is encountered as the operation.</p><h4 id="toc-the-goods">The Goods</h4><ul><li><a href="http://trac.doctrine-project.org/attachment/ticket/1792/fix-parse-between.diff">The Patch</a></li><li><a href="http://trac.doctrine-project.org/ticket/1792">The Ticket</a></li></ul><p>Guilherme from the team messaged me last night to let me know he's going to commit the patch.  I just checked and it's not there yet, so if you need this fix immediately, you can apply the patch above.</p> ]]></content:encoded> <wfw:commentRss>http://ajbrown.org/blog/2008/12/30/new-doctrine-patch-between-relation-alias-parsing.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
