mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
BC: Expected Doctrine\ORM\Query\Lexer::T_ALIASED_NAME, got 'Member' #5991
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @caugner on GitHub (Jun 17, 2018).
Originally assigned to: @lcobucci on GitHub.
BC Break Report
Summary
I have an entity
Member(with a fieldid), and determine the maximumidas follows:Previous behavior
It used to return the highest
id(in 2.5.x).Current behavior
This throws a
QueryExceptionnow (in 2.6.1):How to reproduce
See code snippet above.
@Warxcell commented on GitHub (Aug 11, 2018):
Can you try following instead:
<?php $em->getRepository('Member') ->createQueryBuilder('m') ->select('MAX(m.id)') ->getQuery() ->getSingleScalarResult();@caugner commented on GitHub (Aug 12, 2018):
@Warxcell Thanks for your response. I can't spot a difference between your snippet and mine, could you elaborate on that?
@Warxcell commented on GitHub (Aug 12, 2018):
@caugner Opps. Sorry, my wrong. I edited my response.
@lcobucci commented on GitHub (Aug 12, 2018):
@caugner as pointed out by @Warxcell, the method
EntityRepository#createQueryBuilder()requires an argument - which is not provided by your snippet. That argument is mandatory for a very long time.Can you double check on your code if you're really not providing that argument? That's also supposed to raise a fatal error in PHP 7.1+ (it was a warning before).
@caugner commented on GitHub (Aug 12, 2018):
@lcobucci I was on PHP 7.1 when I updated from 2.5.1 to 2.6.1, and I'm pretty sure it neither raised a fatal error nor a warning (I have PHP error reporting via email that includes warnings); hence the BC Break Report.
As this issue has served its purpose though, I'm closing it now.
@Warxcell @lcobucci Thank you for explaining the reason for this exception.
@lcobucci commented on GitHub (Aug 12, 2018):
@caugner glad it helped 👍
The fact that nothing was reported is quite disturbing and I'd recommend you to review your configuration - you can check PHP's behaviour here: https://3v4l.org/7rVFR.
@Limado commented on GitHub (May 31, 2020):
I'm having a similar issue.
My code:
$groups = $em->getRepository('Group')
->createQueryBuilder('g')
->where('g.users LIKE :myUserId')
->setParameter('myUserId', '%' . $user->getId() . '%')
->getQuery()
->getResult();
the error i'm getting :
Doctrine\ORM\Query\QueryException: [Syntax Error] line 0, col 14: Error: Expected Doctrine\ORM\Query\Lexer::T_ALIASED_NAME, got 'Group'
Tried 3 diferent way of building DQL, always getting same error.
_dql: "SELECT g FROM Group g WHERE g.users LIKE :myUserId"
@Warxcell commented on GitHub (May 31, 2020):
@Limado Don't use Group. It's reserved word.
@yassineMessaoud9 commented on GitHub (Apr 10, 2022):
i the same error:
My code :
`
public function updateU($password,$email): ?Utilisateur
{
$qb = $this->getEntityManager()
->createQueryBuilder()
->update(Utilisateur::class,'u');
$qb
->where($qb->expr()->eq('u.motpasse',':password'))
->andWhere($qb->expr()->eq('u.email',':email'))
->setParameter('password',$password)
->setParameter('email',$email);
}
`
Error:
[Syntax Error] line 0, col 32: Error: Expected Doctrine\ORM\Query\Lexer::T_SET, got 'WHERE'