select('u.id') ->from('User u') ->where("CURRENT_DATE() BETWEEN u.Subscription.begin AND u.Subscription.end") ->addWhere( 'u.id != 5' ); Since the between operands are relational aliases, and not [...]" />

New Doctrine Patch: BETWEEN relation alias parsing

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.

$q1 = Doctrine_Query::create()
    ->select('u.id') ->from('User u') ->where("CURRENT_DATE() BETWEEN u.Subscription.begin AND u.Subscription.end")
    ->addWhere( 'u.id != 5' );

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.

The Goods

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.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Printed from: http://ajbrown.org/blog/2008/12/30/new-doctrine-patch-between-relation-alias-parsing.html .
© © A.J. Brown 2010.

1 Comment  

RSS feed for comments on this post