Skip to content

Commit

Permalink
Fixed phpunit tests for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
jbtronics committed Jun 13, 2024
1 parent 07f1ce5 commit 33a5e70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Controller/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ public function addPart(Request $request, EntityManagerInterface $entityManager,
//Preset the BOM entries with the selected parts, when the form was not submitted yet
$preset_data = new ArrayCollection();
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);
if (null !== $part) {
//If there is already a BOM entry for this part, we use this one (we edit it then)
Expand Down
3 changes: 2 additions & 1 deletion src/Repository/DBElementRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function changeID(AbstractDBElement $element, int $new_id): void

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

return $q->getResult();
Expand Down

0 comments on commit 33a5e70

Please sign in to comment.