Skip to content


DDC-2764: An orderBy on Criteria leads to DQL semantical error #3510

doctrinebot opened this Issue · 6 comments

2 participants


Jira issue originally created by user sandermarechal:

Example code:

$criteria = Criteria::create();
$criteria->orderBy(array('field' => Criteria::DESC));

$qb = $em->getRepository('Entity')->createQueryBuilder('e');


That gives:

[Semantical Error] line 0, col 53 near 'field DESC': Error: 'field' is not defined.


Comment created by @ocramius:

What is the generated DQL? And is it valid?


Comment created by sandermarechal:

The generated DQL comes out as "SELECT e FROM Entity e ORDER BY field DESC". I think it's missing the entity alias in the order by clause.


Comment created by sandermarechal:

If you want I can create a Pull Request with a failing test case for this. I just have no idea how I should go about fixing this bug.


Comment created by stof:

the alias should be prepended to the field before adding the sort in


Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.4.2 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.