Skip to content

Commit aa6232a

Browse files
committed
Fix edge case when value to be matched is an array of null values
1 parent f123d33 commit aa6232a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Persisters/Entity/BasicEntityPersister.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,11 @@ public function getSelectConditionStatementSQL($field, $value, $assoc = null, $c
17531753
$in = $column . ' ' . sprintf(self::$comparisonMap[$comparison], $placeholders);
17541754

17551755
if ($nullKeys) {
1756-
$selectedColumns[] = sprintf('(%s OR %s IS NULL)', $in, $column);
1756+
if ($nonNullValues) {
1757+
$selectedColumns[] = sprintf('(%s OR %s IS NULL)', $in, $column);
1758+
} else {
1759+
$selectedColumns[] = $column . ' IS NULL';
1760+
}
17571761
} else {
17581762
$selectedColumns[] = $in;
17591763
}

tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function testSelectConditionStatementNeqNull(): void
133133
public function testSelectConditionStatementWithMultipleValuesContainingNull(): void
134134
{
135135
self::assertEquals(
136-
'(t0.id IN (?) OR t0.id IS NULL)',
136+
't0.id IS NULL',
137137
$this->persister->getSelectConditionStatementSQL('id', [null])
138138
);
139139

@@ -146,6 +146,11 @@ public function testSelectConditionStatementWithMultipleValuesContainingNull():
146146
'(t0.id IN (?) OR t0.id IS NULL)',
147147
$this->persister->getSelectConditionStatementSQL('id', [123, null])
148148
);
149+
150+
self::assertEquals(
151+
'(t0.id IN (?, ?) OR t0.id IS NULL)',
152+
$this->persister->getSelectConditionStatementSQL('id', [123, null, 234])
153+
);
149154
}
150155

151156
public function testCountCondition(): void

0 commit comments

Comments
 (0)