0
votes

So I'm trying to do a join in a query but doctrine is doing its usually and throwing back errors that are as useful as a broken leg.

Can anyone advice on where I am going wrong here. The error message I am getting; debug: [Syntax Error] line 0, col -1: Error: Expected Doctrine\ORM\Query\Lexer::T_IDENTIFIER, got end of string. in file "./vendor/symfony/doctrine-bridge/Messenger/DoctrineTransactionMiddleware.php" on line 64

Assessment entity

 /**
 * @var Candidate
 * @ORM\ManyToOne(
 *          targetEntity="App\Domain\Candidate\Candidate",
 *          inversedBy="assessments")
 * @ORM\JoinColumn(nullable=false)
 */
private $candidate;

Candidate entity

 /**
 * @var Assessment[]|Collection
 * @ORM\OneToMany(
 *      targetEntity="App\Domain\Assessment\Assessment",
 *      mappedBy="candidate",
 *      cascade={"persist"})
 * @ORM\JoinColumn(nullable=false)
 */
private $assessments;

Doctrine query

$qb = $this->entityManager->createQueryBuilder();

$qb->select('ca')
    ->from(Candidate::class, 'ca')
    ->innerJoin('ca.assessments', 'as');
1
Maybe completely wrong, but as is a reserved word, try changing your alias in your join to something else and see if you get the same issue. Can't see anything else obvious. - naththedeveloper
Put this as an answer please, its sad that doctrine doesn't give back effective errors :'( - Luke Pring
Yeh, I pretty much ignored the error and just scanned the code, it's all I could see and was a bit of a stab in the dark - but glad you got it resolved. - naththedeveloper

1 Answers

1
votes

You're using an alias in your join which is a reserved keyword (as).

$qb->select('ca')
    ->from(Candidate::class, 'ca')
    ->innerJoin('ca.assessments', 'as'); // <-- change this alias

Change as in your join to something else.