Skip to content


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

doctrinebot opened this Issue · 4 comments

2 participants


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(, 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 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 to solve this issue by keeping the parser as-is and only rewriting the returned class




Comment created by mzach:

Attached modified classes for easier review


Comment created by @beberlei:



Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.0-BETA1 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.