Ticket #1792 (closed defect: fixed)

Opened 21 months ago

Last modified 20 months ago

[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.

Attachments

fix-parse-between.diff Download (3.5 KB) - added by ajbrown 21 months ago.
Bugfix for Doctrine_Query_Where including Test Case, and supporting Test Model

Change History

Changed 21 months ago by ajbrown

  • summary changed from Using Relation Aliases in BETWEEN clauses throws Doctrine_Query_Exception to [PATCH] Using Relation Aliases in BETWEEN clauses throws Doctrine_Query_Exception

Changed 21 months ago by ajbrown

Bugfix for Doctrine_Query_Where including Test Case, and supporting Test Model

Changed 21 months ago by ajbrown

Updated patch. Original patch was case sensitive, requiring BETWEEN to be uppercase.

Changed 20 months ago by guilhermeblanco

  • status changed from new to closed
  • resolution set to fixed

(In [5327]) [1.1] fixes #1792. Fixed usage of relation aliases in BETWEEN queries. Thanks for the great patch/work!

Changed 20 months ago by jwage

  • milestone changed from New to 1.0.6
Note: See TracTickets for help on using tickets.