Error for delete query without alias since 2.6.0 #5823

Closed
opened 2026-01-22 15:18:51 +01:00 by admin · 4 comments
Owner

Originally created by @dmaicher on GitHub (Dec 26, 2017).

Originally assigned to: @lcobucci on GitHub.

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?

Originally created by @dmaicher on GitHub (Dec 26, 2017). Originally assigned to: @lcobucci on GitHub. This used to work with `2.5.x`: ```php $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: ```php $em->createQueryBuilder() ->delete(MyEntity::class, 'e') ->getQuery() ->execute(); ``` Is this BC break intentional?
admin added the BugBC BreakRegression labels 2026-01-22 15:18:51 +01:00
admin closed this issue 2026-01-22 15:18:52 +01:00
Author
Owner

@Majkl578 commented on GitHub (Dec 26, 2017):

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.

@Majkl578 commented on GitHub (Dec 26, 2017): 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](https://github.com/doctrine/doctrine2/blob/v2.5.0/docs/en/reference/dql-doctrine-query-language.rst#clauses), alias is actually supposed to be mandatory. It should probably be fixed for 2.6.
Author
Owner

@Tobion commented on GitHub (Jan 7, 2018):

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.

@Tobion commented on GitHub (Jan 7, 2018): 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.
Author
Owner

@lcobucci commented on GitHub (Feb 18, 2018):

#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

@lcobucci commented on GitHub (Feb 18, 2018): #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`
Author
Owner

@Ocramius commented on GitHub (Feb 19, 2018):

Handled in #7077

@Ocramius commented on GitHub (Feb 19, 2018): Handled in #7077
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5823