mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Fixed problem with datatable column sorting on postgresql
This commit is contained in:
parent
7ad2fab53d
commit
6d1553e8d8
2 changed files with 25 additions and 2 deletions
|
@ -129,6 +129,12 @@ class TwoStepORMAdapter extends ORMAdapter
|
||||||
$query->setIdentifierPropertyPath($this->mapFieldToPropertyPath($identifier, $aliases));
|
$query->setIdentifierPropertyPath($this->mapFieldToPropertyPath($identifier, $aliases));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function hasGroupByPart(string $identifier, array $gbList): bool
|
||||||
|
{
|
||||||
|
//Always return true, to fix the issue with the count query, when having mutliple group by parts
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getCount(QueryBuilder $queryBuilder, $identifier): int
|
protected function getCount(QueryBuilder $queryBuilder, $identifier): int
|
||||||
{
|
{
|
||||||
if ($this->query_modifier !== null) {
|
if ($this->query_modifier !== null) {
|
||||||
|
|
|
@ -264,8 +264,8 @@ final class PartsDataTable implements DataTableTypeInterface
|
||||||
->addSelect('part.minamount AS HIDDEN minamount')
|
->addSelect('part.minamount AS HIDDEN minamount')
|
||||||
->from(Part::class, 'part')
|
->from(Part::class, 'part')
|
||||||
|
|
||||||
//This must be the only group by, or the paginator will not work correctly
|
//The other group by fields, are dynamically added by the addJoins method
|
||||||
->addGroupBy('part.id');
|
->addGroupBy('part');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDetailQuery(QueryBuilder $builder, array $filter_results): void
|
private function getDetailQuery(QueryBuilder $builder, array $filter_results): void
|
||||||
|
@ -356,35 +356,52 @@ final class PartsDataTable implements DataTableTypeInterface
|
||||||
|
|
||||||
if (str_contains($dql, '_category')) {
|
if (str_contains($dql, '_category')) {
|
||||||
$builder->leftJoin('part.category', '_category');
|
$builder->leftJoin('part.category', '_category');
|
||||||
|
$builder->addGroupBy('_category');
|
||||||
}
|
}
|
||||||
if (str_contains($dql, '_master_picture_attachment')) {
|
if (str_contains($dql, '_master_picture_attachment')) {
|
||||||
$builder->leftJoin('part.master_picture_attachment', '_master_picture_attachment');
|
$builder->leftJoin('part.master_picture_attachment', '_master_picture_attachment');
|
||||||
|
$builder->addGroupBy('_master_picture_attachment');
|
||||||
}
|
}
|
||||||
if (str_contains($dql, '_partLots') || str_contains($dql, '_storelocations')) {
|
if (str_contains($dql, '_partLots') || str_contains($dql, '_storelocations')) {
|
||||||
$builder->leftJoin('part.partLots', '_partLots');
|
$builder->leftJoin('part.partLots', '_partLots');
|
||||||
$builder->leftJoin('_partLots.storage_location', '_storelocations');
|
$builder->leftJoin('_partLots.storage_location', '_storelocations');
|
||||||
|
//Do not group by many-to-* relations, as it would restrict the COUNT having clauses to be maximum 1
|
||||||
|
//$builder->addGroupBy('_partLots');
|
||||||
|
//$builder->addGroupBy('_storelocations');
|
||||||
}
|
}
|
||||||
if (str_contains($dql, '_footprint')) {
|
if (str_contains($dql, '_footprint')) {
|
||||||
$builder->leftJoin('part.footprint', '_footprint');
|
$builder->leftJoin('part.footprint', '_footprint');
|
||||||
|
$builder->addGroupBy('_footprint');
|
||||||
}
|
}
|
||||||
if (str_contains($dql, '_manufacturer')) {
|
if (str_contains($dql, '_manufacturer')) {
|
||||||
$builder->leftJoin('part.manufacturer', '_manufacturer');
|
$builder->leftJoin('part.manufacturer', '_manufacturer');
|
||||||
|
$builder->addGroupBy('_manufacturer');
|
||||||
}
|
}
|
||||||
if (str_contains($dql, '_orderdetails') || str_contains($dql, '_suppliers')) {
|
if (str_contains($dql, '_orderdetails') || str_contains($dql, '_suppliers')) {
|
||||||
$builder->leftJoin('part.orderdetails', '_orderdetails');
|
$builder->leftJoin('part.orderdetails', '_orderdetails');
|
||||||
$builder->leftJoin('_orderdetails.supplier', '_suppliers');
|
$builder->leftJoin('_orderdetails.supplier', '_suppliers');
|
||||||
|
//Do not group by many-to-* relations, as it would restrict the COUNT having clauses to be maximum 1
|
||||||
|
//$builder->addGroupBy('_orderdetails');
|
||||||
|
//$builder->addGroupBy('_suppliers');
|
||||||
}
|
}
|
||||||
if (str_contains($dql, '_attachments')) {
|
if (str_contains($dql, '_attachments')) {
|
||||||
$builder->leftJoin('part.attachments', '_attachments');
|
$builder->leftJoin('part.attachments', '_attachments');
|
||||||
|
//Do not group by many-to-* relations, as it would restrict the COUNT having clauses to be maximum 1
|
||||||
|
//$builder->addGroupBy('_attachments');
|
||||||
}
|
}
|
||||||
if (str_contains($dql, '_partUnit')) {
|
if (str_contains($dql, '_partUnit')) {
|
||||||
$builder->leftJoin('part.partUnit', '_partUnit');
|
$builder->leftJoin('part.partUnit', '_partUnit');
|
||||||
|
$builder->addGroupBy('_partUnit');
|
||||||
}
|
}
|
||||||
if (str_contains($dql, '_parameters')) {
|
if (str_contains($dql, '_parameters')) {
|
||||||
$builder->leftJoin('part.parameters', '_parameters');
|
$builder->leftJoin('part.parameters', '_parameters');
|
||||||
|
//Do not group by many-to-* relations, as it would restrict the COUNT having clauses to be maximum 1
|
||||||
|
//$builder->addGroupBy('_parameters');
|
||||||
}
|
}
|
||||||
if (str_contains($dql, '_projectBomEntries')) {
|
if (str_contains($dql, '_projectBomEntries')) {
|
||||||
$builder->leftJoin('part.project_bom_entries', '_projectBomEntries');
|
$builder->leftJoin('part.project_bom_entries', '_projectBomEntries');
|
||||||
|
//Do not group by many-to-* relations, as it would restrict the COUNT having clauses to be maximum 1
|
||||||
|
//$builder->addGroupBy('_projectBomEntries');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $builder;
|
return $builder;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue