I'm trying to convert a MySQL8 query to Doctrine DQL in Symfony4. I used to https://github.com/beberlei/DoctrineExtensions extensions. But there are still errors.
Query is work well.
SELECT id, machine_amount, LAG(machine_amount) OVER ( PARTITION BY machine_id ORDER BY id ) AS prevField FROM machine_income
repositoryClass
$q = $this->createQueryBuilder('mi');
$q->select('mi.id, mi.machineAmount');
$q->addSelect('LAG(mi.machineAmount) OVER (PARTITION BY mi.machine ORDER BY mi.id) AS prevField');
return $q->getQuery()->getSQL();
doctrine.yaml
doctrine:
orm:
dql:
string_functions:
lag: DoctrineExtensions\Query\Mysql\Lag
over: DoctrineExtensions\Query\Mysql\Over
DQL out
SELECT mi.id, mi.machineAmount, LAG(mi.machineAmount) OVER (PARTITION BY mi.machine ORDER BY mi.id) AS prevField FROM App\Entity\MachineIncome mi
When I try to create getSQL() I saw error.
error
[Syntax Error] line 0, col 59: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '('
any help?