Orm: Error for delete query without alias since 2.6.0

Created on 26 Dec 2017  路  4Comments  路  Source: doctrine/orm

This used to work with 2.5.x:

$em->createQueryBuilder()
    ->delete(MyEntity::class)
    ->getQuery()
    ->execute();

Now with 2.6.0 I get this error:

[Syntax Error] line 0, col -1: Error: Expected Doctrine\ORM\Query\Lexer::T_IDENTIFIER, got end of string. (Doctrine\ORM\Query\QueryException)

If I add an alias it works again:

$em->createQueryBuilder()
    ->delete(MyEntity::class, 'e')
    ->getQuery()
    ->execute();

Is this BC break intentional?

BC Break Bug Regression

All 4 comments

Similar to #6932 (missing alias in SELECT, here it's FROM), it'll be caused by the same source.
As you can see here in EBNF for 2.5.0, alias is actually supposed to be mandatory.

It should probably be fixed for 2.6.

Can confirm the bug. I'm als affected with something like $em->createQuery('DELETE FROM '.MyEntity::class)->execute();.
I don't think the alias should be required for simple queries like this.

7077 is fixing the BC-break and discussing the update of the grammar to align with JPA 2.2 for v2.6.x and v3.0

Handled in #7077

Was this page helpful?
0 / 5 - 0 ratings