From 01fc6524a43127658137c7fa2bc0caabf31dc83d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 4 Nov 2024 23:46:45 +0100 Subject: [PATCH] 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 --- src/DataTables/PartsDataTable.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DataTables/PartsDataTable.php b/src/DataTables/PartsDataTable.php index 28c564b1..f62d9083 100644 --- a/src/DataTables/PartsDataTable.php +++ b/src/DataTables/PartsDataTable.php @@ -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')