Fixed phpunit tests for postgres

This commit is contained in:
Jan Böhmer 2024-06-13 22:19:17 +02:00
parent 07f1ce5822
commit 33a5e70b70
2 changed files with 7 additions and 1 deletions

View file

@ -207,6 +207,11 @@ class ProjectController extends AbstractController
//Preset the BOM entries with the selected parts, when the form was not submitted yet //Preset the BOM entries with the selected parts, when the form was not submitted yet
$preset_data = new ArrayCollection(); $preset_data = new ArrayCollection();
foreach (explode(',', (string) $request->get('parts', '')) as $part_id) { foreach (explode(',', (string) $request->get('parts', '')) as $part_id) {
//Skip empty part IDs. Postgres seems to be especially sensitive to empty strings, as it does not allow them in integer columns
if ($part_id === '') {
continue;
}
$part = $entityManager->getRepository(Part::class)->find($part_id); $part = $entityManager->getRepository(Part::class)->find($part_id);
if (null !== $part) { if (null !== $part) {
//If there is already a BOM entry for this part, we use this one (we edit it then) //If there is already a BOM entry for this part, we use this one (we edit it then)

View file

@ -79,7 +79,7 @@ class DBElementRepository extends EntityRepository
/** /**
* Find all elements that match a list of IDs. * Find all elements that match a list of IDs.
* * They are ordered by IDs in an ascending order.
* @return AbstractDBElement[] * @return AbstractDBElement[]
* @phpstan-return list<TEntityClass> * @phpstan-return list<TEntityClass>
*/ */
@ -89,6 +89,7 @@ class DBElementRepository extends EntityRepository
$q = $qb->select('element') $q = $qb->select('element')
->where('element.id IN (?1)') ->where('element.id IN (?1)')
->setParameter(1, $ids) ->setParameter(1, $ids)
->orderBy('element.id', 'ASC')
->getQuery(); ->getQuery();
return $q->getResult(); return $q->getResult();