fix: update database queries for mysql 8 compatibility
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -118,7 +118,7 @@ class DestinationRepository extends ServiceEntityRepository
|
||||
|
||||
return $qb
|
||||
->select('destination.hotel', 'destination.hotelCode', 'destination.hotelBusProId')
|
||||
->groupBy('destination.hotelBusProId')
|
||||
->groupBy('destination.hotelBusProId', 'destination.hotel', 'destination.hotelCode')
|
||||
->orderBy('destination.hotel', 'ASC')
|
||||
->getQuery()
|
||||
->getArrayResult()
|
||||
|
||||
Reference in New Issue
Block a user