Skip to content

Commit ed59be1

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix-zizmor-workflows
# Conflicts: # .github/workflows/mutation.yml
2 parents 26956b2 + 9a350ad commit ed59be1

5 files changed

Lines changed: 37 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Bug #484: Fix building range-type column definitions (@Tigrov)
88
- Enh #489: Clarify return type of `phpTypecast()` methods for range columns (@Tigrov)
99
- New #492: Add `getBounds()` method to range values (@Tigrov)
10+
- Bug #495: Add missed parameters for building expressions in `ArrayOverlapsBuilder` and `JsonOverlapsBuilder` classes (@Tigrov)
1011

1112
## 2.0.1 February 07, 2026
1213

src/Builder/ArrayOverlapsBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
public function build(ExpressionInterface $expression, array &$params = []): string
3333
{
3434
$column = $expression->column instanceof ExpressionInterface
35-
? $this->queryBuilder->buildExpression($expression->column)
35+
? $this->queryBuilder->buildExpression($expression->column, $params)
3636
: $this->queryBuilder->getQuoter()->quoteColumnName($expression->column);
3737
$values = $expression->values;
3838

src/Builder/JsonOverlapsBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
public function build(ExpressionInterface $expression, array &$params = []): string
3333
{
3434
$column = $expression->column instanceof ExpressionInterface
35-
? $this->queryBuilder->buildExpression($expression->column)
35+
? $this->queryBuilder->buildExpression($expression->column, $params)
3636
: $this->queryBuilder->getQuoter()->quoteColumnName($expression->column);
3737
$values = $expression->values;
3838

src/Column/ColumnFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ protected function isType(string $type): bool
179179
protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnInterface $column): mixed
180180
{
181181
/** @var string $value */
182-
$value = preg_replace("/::[^:']+$/", '$1', $defaultValue);
182+
$value = preg_replace("/::[^:']+$/", '', $defaultValue);
183183

184184
if (str_starts_with($value, "B'") && $value[-1] === "'") {
185185
return $column->phpTypecast(substr($value, 2, -1));

tests/QueryBuilderTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,39 @@ public function testOverlapsConditionOperator(Closure|iterable|ExpressionInterfa
539539
$this->assertSame($expectedCount, $count);
540540
}
541541

542+
public function testArrayOverlapsWithExpressionColumnParams(): void
543+
{
544+
$db = $this->getSharedConnection();
545+
$qb = $db->getQueryBuilder();
546+
$params = [];
547+
548+
$sql = $qb->buildExpression(
549+
new ArrayOverlaps(new Expression('array_remove(column, :empty)', [':empty' => null]), [1, 2, 3]),
550+
$params,
551+
);
552+
553+
$this->assertSame('array_remove(column, :empty)::int[] && ARRAY[1,2,3]::int[]', $sql);
554+
$this->assertSame([':empty' => null], $params);
555+
}
556+
557+
public function testJsonOverlapsWithExpressionColumnParams(): void
558+
{
559+
$db = $this->getSharedConnection();
560+
$qb = $db->getQueryBuilder();
561+
$params = [];
562+
563+
$sql = $qb->buildExpression(
564+
new JsonOverlaps(new Expression('jsonb_path_query_array(column, :path)', [':path' => '$[*]']), [1, 2, 3]),
565+
$params,
566+
);
567+
568+
$this->assertSame(
569+
'ARRAY(SELECT jsonb_array_elements_text(jsonb_path_query_array(column, :path)::jsonb))::int[] && ARRAY[1,2,3]::int[]',
570+
$sql,
571+
);
572+
$this->assertSame([':path' => '$[*]'], $params);
573+
}
574+
542575
#[DataProviderExternal(QueryBuilderProvider::class, 'buildColumnDefinition')]
543576
public function testBuildColumnDefinition(string $expected, Closure|ColumnInterface|string $column): void
544577
{

0 commit comments

Comments
 (0)