mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-19 09:51:45 +00:00
Try to fix "Iterate with fetch join in class App\Entity\Parts\PartLot using association part not allowed." when opening BOM 2nd try
This commit is contained in:
parent
75890e199a
commit
9516062e82
1 changed files with 17 additions and 6 deletions
|
|
@ -183,9 +183,10 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
->add('storageLocations', TextColumn::class, [
|
->add('storelocation', TextColumn::class, [
|
||||||
'label' => 'part.table.storeLocations',
|
'label' => $this->translator->trans('part.table.storeLocations'),
|
||||||
'orderField' => 'NATSORT(MIN(storageLocations.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))',
|
||||||
'visible' => false,
|
'visible' => false,
|
||||||
'render' => function ($value, ProjectBOMEntry $context) {
|
'render' => function ($value, ProjectBOMEntry $context) {
|
||||||
if ($context->getPart() !== null) {
|
if ($context->getPart() !== null) {
|
||||||
|
|
@ -194,7 +195,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
])
|
], alias: 'storage_location')
|
||||||
|
|
||||||
->add('addedDate', LocaleDateTimeColumn::class, [
|
->add('addedDate', LocaleDateTimeColumn::class, [
|
||||||
'label' => $this->translator->trans('part.table.addedDate'),
|
'label' => $this->translator->trans('part.table.addedDate'),
|
||||||
|
|
@ -229,12 +230,22 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
||||||
->from(ProjectBOMEntry::class, 'bom_entry')
|
->from(ProjectBOMEntry::class, 'bom_entry')
|
||||||
->leftJoin('bom_entry.part', 'part')
|
->leftJoin('bom_entry.part', 'part')
|
||||||
->leftJoin('part.category', 'category')
|
->leftJoin('part.category', 'category')
|
||||||
|
->leftJoin('part.partLots', 'partLots')
|
||||||
|
->leftJoin('partLots.storage_location', 'storelocations')
|
||||||
->leftJoin('part.footprint', 'footprint')
|
->leftJoin('part.footprint', 'footprint')
|
||||||
->leftJoin('part.manufacturer', 'manufacturer')
|
->leftJoin('part.manufacturer', 'manufacturer')
|
||||||
->leftJoin('part.partLots', 'partLots')
|
->leftJoin('part.partCustomState', 'partCustomState')
|
||||||
->leftJoin('partLots.storage_location', 'storageLocations')
|
|
||||||
->where('bom_entry.project = :project')
|
->where('bom_entry.project = :project')
|
||||||
->setParameter('project', $options['project'])
|
->setParameter('project', $options['project'])
|
||||||
|
|
||||||
|
//We have to group by all elements, or only the first sub elements of an association is fetched! (see issue #190)
|
||||||
|
->addGroupBy('part')
|
||||||
|
->addGroupBy('partLots')
|
||||||
|
->addGroupBy('category')
|
||||||
|
->addGroupBy('storelocations')
|
||||||
|
->addGroupBy('footprint')
|
||||||
|
->addGroupBy('manufacturer')
|
||||||
|
->addGroupBy('partCustomState')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue