mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Replaced the non standard IFNULL function which postgres does not know with the COALSCE function
This commit is contained in:
parent
33a5e70b70
commit
c58ff5861d
3 changed files with 16 additions and 4 deletions
|
@ -44,7 +44,6 @@ doctrine:
|
||||||
dql:
|
dql:
|
||||||
string_functions:
|
string_functions:
|
||||||
regexp: DoctrineExtensions\Query\Mysql\Regexp
|
regexp: DoctrineExtensions\Query\Mysql\Regexp
|
||||||
ifnull: DoctrineExtensions\Query\Mysql\IfNull
|
|
||||||
field: DoctrineExtensions\Query\Mysql\Field
|
field: DoctrineExtensions\Query\Mysql\Field
|
||||||
field2: App\Doctrine\Functions\Field2
|
field2: App\Doctrine\Functions\Field2
|
||||||
|
|
||||||
|
|
|
@ -345,7 +345,7 @@ final class PartsDataTable implements DataTableTypeInterface
|
||||||
//Calculate amount sum using a subquery, so we can filter and sort by it
|
//Calculate amount sum using a subquery, so we can filter and sort by it
|
||||||
$builder->addSelect(
|
$builder->addSelect(
|
||||||
'(
|
'(
|
||||||
SELECT IFNULL(SUM(partLot.amount), 0.0)
|
SELECT COALESCE(SUM(partLot.amount), 0.0)
|
||||||
FROM '.PartLot::class.' partLot
|
FROM '.PartLot::class.' partLot
|
||||||
WHERE partLot.part = part.id
|
WHERE partLot.part = part.id
|
||||||
AND partLot.instock_unknown = false
|
AND partLot.instock_unknown = false
|
||||||
|
|
|
@ -48,7 +48,7 @@ class DatatablesAvailabilityTest extends WebTestCase
|
||||||
/**
|
/**
|
||||||
* @dataProvider urlProvider
|
* @dataProvider urlProvider
|
||||||
*/
|
*/
|
||||||
public function testDataTable(string $url): void
|
public function testDataTable(string $url, ?array $ordering = null): void
|
||||||
{
|
{
|
||||||
//We have localized routes
|
//We have localized routes
|
||||||
$url = '/en'.$url;
|
$url = '/en'.$url;
|
||||||
|
@ -68,7 +68,14 @@ class DatatablesAvailabilityTest extends WebTestCase
|
||||||
'PHP_AUTH_PW' => 'test',
|
'PHP_AUTH_PW' => 'test',
|
||||||
]);
|
]);
|
||||||
$client->catchExceptions(false);
|
$client->catchExceptions(false);
|
||||||
$client->request('POST', $url, ['_dt' => 'dt']);
|
|
||||||
|
$post = ['_dt' => 'dt'];
|
||||||
|
|
||||||
|
if ($ordering) {
|
||||||
|
$post['order'] = $ordering;
|
||||||
|
}
|
||||||
|
|
||||||
|
$client->request('POST', $url, $post);
|
||||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||||
$this->assertJson($client->getResponse()->getContent());
|
$this->assertJson($client->getResponse()->getContent());
|
||||||
}
|
}
|
||||||
|
@ -93,4 +100,10 @@ class DatatablesAvailabilityTest extends WebTestCase
|
||||||
yield ['/category/1/parts?part_filter%5Bname%5D%5Boperator%5D=%3D&part_filter%5Bname%5D%5Bvalue%5D=BC547&part_filter%5Bcategory%5D%5Boperator%5D=INCLUDING_CHILDREN&part_filter%5Btags%5D%5Boperator%5D=ANY&part_filter%5Btags%5D%5Bvalue%5D=Test&part_filter%5Bsubmit%5D='];
|
yield ['/category/1/parts?part_filter%5Bname%5D%5Boperator%5D=%3D&part_filter%5Bname%5D%5Bvalue%5D=BC547&part_filter%5Bcategory%5D%5Boperator%5D=INCLUDING_CHILDREN&part_filter%5Btags%5D%5Boperator%5D=ANY&part_filter%5Btags%5D%5Bvalue%5D=Test&part_filter%5Bsubmit%5D='];
|
||||||
yield ['/category/1/parts?part_filter%5Bcategory%5D%5Boperator%5D=INCLUDING_CHILDREN&part_filter%5Bstorelocation%5D%5Boperator%5D=%3D&part_filter%5Bstorelocation%5D%5Bvalue%5D=1&part_filter%5BattachmentsCount%5D%5Boperator%5D=%3D&part_filter%5BattachmentsCount%5D%5Bvalue1%5D=3&part_filter%5Bsubmit%5D='];
|
yield ['/category/1/parts?part_filter%5Bcategory%5D%5Boperator%5D=INCLUDING_CHILDREN&part_filter%5Bstorelocation%5D%5Boperator%5D=%3D&part_filter%5Bstorelocation%5D%5Bvalue%5D=1&part_filter%5BattachmentsCount%5D%5Boperator%5D=%3D&part_filter%5BattachmentsCount%5D%5Bvalue1%5D=3&part_filter%5Bsubmit%5D='];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testOrdering(): void
|
||||||
|
{
|
||||||
|
//Amount ordering (which uses the dynamic amount calculation)
|
||||||
|
$this->testDataTable('/parts', [['column' => 9, 'dir' => 'asc']]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue