DDC-478: $qb->expr()->between("alias.myfield", $minValue, $maxValue) cannot be parsed into valid SQL #595

Closed
opened 2026-01-22 12:43:40 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 26, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user mzach:

When using the between() method of the Doctrine\ORM\Query\Expr class, an instance of Doctrine\ORM\Query\Expr\Func is returned, which produces a DQL similar to:

SELECT p FROM MyTest\Domain\Person p WHERE BETWEEN(p.id, 1, 100)

This is expected behaviour following the test available in Doctrine/Tests/ORM/Query/ExprTest.php, unfortunately the parser itself as well as other testcases expect the format to be

SELECT p FROM MyTest\Domain\Person p WHERE p.id BETWEEN 1 AND 100

So every time you call getSql() Doctrine throws an Exception because it tries to access BETWEEN() as a database function, whereas it really is a comparator.

I made a quick fix available at http://www.pastie.org/888251 to solve this issue by keeping the parser as-is and only rewriting the returned class

HTH

Regards,
Michael

Originally created by @doctrinebot on GitHub (Mar 26, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user mzach: When using the between() method of the Doctrine\ORM\Query\Expr class, an instance of Doctrine\ORM\Query\Expr\Func is returned, which produces a DQL similar to: SELECT p FROM MyTest\Domain\Person p WHERE BETWEEN(p.id, 1, 100) This is expected behaviour following the test available in Doctrine/Tests/ORM/Query/ExprTest.php, unfortunately the parser itself as well as other testcases expect the format to be SELECT p FROM MyTest\Domain\Person p WHERE p.id BETWEEN 1 AND 100 So every time you call getSql() Doctrine throws an Exception because it tries to access BETWEEN() as a database function, whereas it really is a comparator. I made a quick fix available at http://www.pastie.org/888251 to solve this issue by keeping the parser as-is and only rewriting the returned class HTH Regards, Michael
admin added the Bug label 2026-01-22 12:43:40 +01:00
admin closed this issue 2026-01-22 12:43:42 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 26, 2010):

Comment created by mzach:

Attached modified classes for easier review

@doctrinebot commented on GitHub (Mar 26, 2010): Comment created by mzach: Attached modified classes for easier review
Author
Owner

@doctrinebot commented on GitHub (Mar 28, 2010):

Comment created by @beberlei:

Fixed

@doctrinebot commented on GitHub (Mar 28, 2010): Comment created by @beberlei: Fixed
Author
Owner

@doctrinebot commented on GitHub (Mar 28, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Mar 28, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 3 attachments from Jira into https://gist.github.com/9f0d5e12e7051df5a6f4

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 3 attachments from Jira into https://gist.github.com/9f0d5e12e7051df5a6f4 - [10521_Expr.php](https://gist.github.com/9f0d5e12e7051df5a6f4#file-10521_Expr-php) - [10522_Between.php](https://gist.github.com/9f0d5e12e7051df5a6f4#file-10522_Between-php) - [10523_Func.php](https://gist.github.com/9f0d5e12e7051df5a6f4#file-10523_Func-php)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#595