diff --git a/tests/Provider/QueryBuilderProvider.php b/tests/Provider/QueryBuilderProvider.php index 5ec0a512f..a8d11d710 100644 --- a/tests/Provider/QueryBuilderProvider.php +++ b/tests/Provider/QueryBuilderProvider.php @@ -636,4 +636,26 @@ public static function multiOperandFunctionBuilder(): array ], ]; } + + public static function upsertWithMultiOperandFunctions(): array + { + $data = parent::upsertWithMultiOperandFunctions(); + + $data[0][3] = 'INSERT INTO "test_upsert_with_functions"' + . ' ("id", "array_col", "greatest_col", "least_col", "longest_col", "shortest_col")' + . ' VALUES (1, ARRAY[3,4,5]::int[], 5, 5, :qp0, :qp1) ON CONFLICT ("id") DO UPDATE SET' + . ' "array_col"=ARRAY(SELECT DISTINCT UNNEST("test_upsert_with_functions"."array_col"::int4[] || EXCLUDED."array_col"::int4[]) ORDER BY 1)::int4[],' + . ' "greatest_col"=GREATEST("test_upsert_with_functions"."greatest_col", EXCLUDED."greatest_col"),' + . ' "least_col"=LEAST("test_upsert_with_functions"."least_col", EXCLUDED."least_col"),' + . ' "longest_col"=(SELECT value FROM (SELECT "test_upsert_with_functions"."longest_col" AS value UNION SELECT EXCLUDED."longest_col" AS value) AS t ORDER BY LENGTH(value) DESC LIMIT 1),' + . ' "shortest_col"=(SELECT value FROM (SELECT "test_upsert_with_functions"."shortest_col" AS value UNION SELECT EXCLUDED."shortest_col" AS value) AS t ORDER BY LENGTH(value) ASC LIMIT 1)'; + + $data[0][4]['array_col'] = '{1,2,3,4,5}'; + $data[0][5] = [ + ':qp0' => new Param('short', DataType::STRING), + ':qp1' => new Param('short', DataType::STRING), + ]; + + return $data; + } } diff --git a/tests/QueryBuilderTest.php b/tests/QueryBuilderTest.php index 3e93a3a6c..edf9b763a 100644 --- a/tests/QueryBuilderTest.php +++ b/tests/QueryBuilderTest.php @@ -653,4 +653,16 @@ public function testArrayMergeWithTypeWithOrdering( $this->assertSame($expectedResult, $result); } + + #[DataProviderExternal(QueryBuilderProvider::class, 'upsertWithMultiOperandFunctions')] + public function testUpsertWithMultiOperandFunctions( + array $initValues, + array $insertValues, + array $updateValues, + string $expectedSql, + array $expectedResult, + array $expectedParams = [], + ): void { + parent::testUpsertWithMultiOperandFunctions($initValues, $insertValues, $updateValues, $expectedSql, $expectedResult, $expectedParams); + } }