Skip to content

Commit 01fc652

Browse files
committed
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
1 parent 2575e6a commit 01fc652

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/DataTables/PartsDataTable.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ public function configure(DataTable $dataTable, array $options): void
137137
])
138138
->add('storelocation', TextColumn::class, [
139139
'label' => $this->translator->trans('part.table.storeLocations'),
140-
'orderField' => 'NATSORT(_storelocations.name)',
140+
//We need to use a aggregate function to get the first store location, as we have a one-to-many relation
141+
'orderField' => 'NATSORT(MIN(_storelocations.name))',
141142
'render' => fn ($value, Part $context) => $this->partDataTableHelper->renderStorageLocations($context),
142143
], alias: 'storage_location')
143144

0 commit comments

Comments
 (0)