fix: update database queries for mysql 8 compatibility

This commit is contained in:
Björn Fromme
2026-03-15 12:42:28 +01:00
parent 8eaa53c74d
commit 4bffdc46a3
2 changed files with 13 additions and 5 deletions
+12 -4
View File
@@ -5,6 +5,7 @@ namespace App\Repository;
use App\Entity\Application;
use App\Entity\Assignment;
use App\Entity\Teamer;
use App\Entity\Training;
use App\Model\AssignmentFilterDto;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\Query;
@@ -66,7 +67,6 @@ class AssignmentRepository extends ServiceEntityRepository
->select('assignment', 'destination', 'job_profile', 'application', 'disposition')
->innerJoin('assignment.destination', 'destination')
->innerJoin('assignment.jobProfile', 'job_profile')
->leftJoin('job_profile.requiredTrainings', 'required_training')
->where($qb->expr()->andX(
$qb->expr()->orX(
$qb->expr()->gt('destination.dateFrom', ':now'),
@@ -81,7 +81,6 @@ class AssignmentRepository extends ServiceEntityRepository
))
->leftJoin('assignment.applications', 'application', Join::WITH, $qb->expr()->eq('application.teamer', ':teamer'))
->leftJoin('assignment.dispositions', 'disposition', Join::WITH, $qb->expr()->eq('disposition.teamer', ':teamer'))
->groupBy('assignment')
->setParameter('teamer', $teamer)
->setParameter('status', [Assignment::STATUS_DRAFT, Assignment::STATUS_CALLED_OFF])
->setParameter('now', new \DateTimeImmutable())
@@ -89,8 +88,17 @@ class AssignmentRepository extends ServiceEntityRepository
// limit result for teamers not having any trainings AND licences
if (0 === $teamer->getTrainingAttendances()->count() && 0 === $teamer->getLicenses()->count()) {
// Use NOT EXISTS subquery instead of JOIN to avoid duplicates requiring GROUP BY
$subQb = $this->getEntityManager()->createQueryBuilder();
$subQb
->select('1')
->from(Training::class, 'rt')
->join('rt.jobProfiles', 'jp')
->where('jp = job_profile')
;
$qb
->andWhere($qb->expr()->isNull('required_training'))
->andWhere($qb->expr()->not($qb->expr()->exists($subQb->getDQL())))
->andWhere($qb->expr()->eq('job_profile.requiredLicenses', ':requiredLicenses'))
->setParameter('requiredLicenses', '[]')
;
@@ -346,7 +354,7 @@ class AssignmentRepository extends ServiceEntityRepository
$codes = [];
$result = $qb
->select('assignment.id', 'destination.hotelCode')
->select('destination.hotelCode')
->innerJoin('assignment.destination', 'destination')
->groupBy('destination.hotelCode')
->orderBy('destination.hotelCode', 'ASC')