Skip to content

Commit 4053c96

Browse files
authored
Update tests according changes in db (#452)
1 parent e405c73 commit 4053c96

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

‎tests/Provider/QueryBuilderProvider.php‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -622,32 +622,40 @@ public static function multiOperandFunctionBuilder(): array
622622
$stringQuerySql = "(SELECT 'longest'::text)";
623623
$stringParam = new Param('{3,4,5}', DataType::STRING);
624624

625+
$db = self::getDb();
626+
$serverVersion = $db->getServerInfo()->getVersion();
627+
$db->close();
628+
629+
if (version_compare($serverVersion, '10', '<')) {
630+
unset($data['Longest with 1 operand'], $data['Shortest with 1 operand']);
631+
}
632+
625633
$data['Longest with 3 operands'][1][1] = $stringQuery;
626-
$data['Longest with 3 operands'][2] = "(SELECT value FROM (SELECT 'short' AS value UNION SELECT $stringQuerySql"
627-
. ' AS value UNION SELECT :qp0 AS value) AS t ORDER BY LENGTH(value) DESC LIMIT 1)';
634+
$data['Longest with 3 operands'][2] = "(SELECT value FROM (SELECT :qp0 AS value UNION SELECT $stringQuerySql"
635+
. ' AS value UNION SELECT :qp1 AS value) AS t ORDER BY LENGTH(value) DESC LIMIT 1)';
628636
$data['Shortest with 3 operands'][1][1] = $stringQuery;
629-
$data['Shortest with 3 operands'][2] = "(SELECT value FROM (SELECT 'short' AS value UNION SELECT $stringQuerySql"
630-
. ' AS value UNION SELECT :qp0 AS value) AS t ORDER BY LENGTH(value) ASC LIMIT 1)';
637+
$data['Shortest with 3 operands'][2] = "(SELECT value FROM (SELECT :qp0 AS value UNION SELECT $stringQuerySql"
638+
. ' AS value UNION SELECT :qp1 AS value) AS t ORDER BY LENGTH(value) ASC LIMIT 1)';
631639

632640
return [
633641
...$data,
634642
'ArrayMerge with 1 operand' => [
635643
ArrayMerge::class,
636-
['ARRAY[1,2,3]'],
637-
'(ARRAY[1,2,3])',
644+
[[1, 2, 3]],
645+
'(ARRAY[1,2,3]::int[])',
638646
[1, 2, 3],
639647
],
640648
'ArrayMerge with 2 operands' => [
641649
ArrayMerge::class,
642-
['ARRAY[1,2,3]', $stringParam],
643-
'ARRAY(SELECT DISTINCT UNNEST(ARRAY[1,2,3] || :qp0))',
650+
[[1, 2, 3], $stringParam],
651+
'ARRAY(SELECT DISTINCT UNNEST(ARRAY[1,2,3]::int[] || :qp0))',
644652
[1, 2, 3, 4, 5],
645653
[':qp0' => $stringParam],
646654
],
647655
'ArrayMerge with 4 operands' => [
648656
ArrayMerge::class,
649-
['ARRAY[1,2,3]', [5, 6, 7], $stringParam, self::getDb()->select(new ArrayValue([9, 10]))],
650-
'ARRAY(SELECT DISTINCT UNNEST(ARRAY[1,2,3] || ARRAY[5,6,7]::int[] || :qp0 || (SELECT ARRAY[9,10]::int[])))',
657+
[[1, 2, 3], new ArrayValue([5, 6, 7]), $stringParam, self::getDb()->select(new ArrayValue([9, 10]))],
658+
'ARRAY(SELECT DISTINCT UNNEST(ARRAY[1,2,3]::int[] || ARRAY[5,6,7]::int[] || :qp0 || (SELECT ARRAY[9,10]::int[])))',
651659
[1, 2, 3, 4, 5, 6, 7, 9, 10],
652660
[
653661
':qp0' => $stringParam,

‎tests/QueryBuilderTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,15 +637,15 @@ public function testArrayMergeWithTypeWithOrdering(
637637

638638
$stringParam = new Param('{4,3,5}', DataType::STRING);
639639
$arrayMerge = (new ArrayMerge(
640-
'ARRAY[2,1,3]',
641-
[6, 5, 7],
640+
[2, 1, 3],
641+
new ArrayValue([6, 5, 7]),
642642
$stringParam,
643643
self::getDb()->select(new ArrayValue([10, 9])),
644644
))->type($type)->ordered();
645645
$params = [];
646646

647647
$this->assertSame(
648-
"ARRAY(SELECT DISTINCT UNNEST(ARRAY[2,1,3]$typeHint || ARRAY[6,5,7]::int[]$typeHint || :qp0$typeHint || (SELECT ARRAY[10,9]::int[])$typeHint) ORDER BY 1)$typeHint",
648+
"ARRAY(SELECT DISTINCT UNNEST(ARRAY[2,1,3]::int[]$typeHint || ARRAY[6,5,7]::int[]$typeHint || :qp0$typeHint || (SELECT ARRAY[10,9]::int[])$typeHint) ORDER BY 1)$typeHint",
649649
$qb->buildExpression($arrayMerge, $params)
650650
);
651651
$this->assertSame([':qp0' => $stringParam], $params);

0 commit comments

Comments
 (0)