Ticket #1792 (closed defect: fixed)
[PATCH] Using Relation Aliases in BETWEEN clauses throws Doctrine_Query_Exception
| Reported by: | ajbrown | Owned by: | romanb |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.0.6 |
| Component: | Query/Hydration | Version: | 1.1-DEV |
| Severity: | Keywords: | BETWEEN, Doctrine_Query_Where | |
| Cc: | Has Test: | yes | |
| Status: | Pending Core Response | Has Patch: | yes |
Description
Running a query with a where() clause including a BETWEEN expression results in Unexpected Doctrine_Query_Exception with message [Couldn't get short alias ... being thrown if the expressions of the BETWEEN operation are relation aliases.
Example Exceptional Query:
$q1 = Doctrine_Query::create()
->select('u.id') ->from('User u') ->where("CURRENT_DATE() BETWEEN u.Subscription.begin AND u.Subscription.begin")
->addWhere( 'u.id != 5' );
The issue is parsing that BETWEEN x AND as treated as an operator thus the proper parsing does not take place. If we spilt this clause further, and parse only the expression between BETWEEN and AND, everything works correctly.
I have attached a patch (including supporting unit test) to fix the issue.
