Added a aggregate function for storelocation sorting to avoid exceptions on Postgres

Actually this was not good on other DB types too, but they just ignored the problems.

This fixes issue #734
This commit is contained in:
Jan Böhmer 2024-11-04 23:46:45 +01:00
parent 2575e6a160
commit 01fc6524a4

View file

@ -137,7 +137,8 @@ final class PartsDataTable implements DataTableTypeInterface
])
->add('storelocation', TextColumn::class, [
'label' => $this->translator->trans('part.table.storeLocations'),
'orderField' => 'NATSORT(_storelocations.name)',
//We need to use a aggregate function to get the first store location, as we have a one-to-many relation
'orderField' => 'NATSORT(MIN(_storelocations.name))',
'render' => fn ($value, Part $context) => $this->partDataTableHelper->renderStorageLocations($context),
], alias: 'storage_location')