Skip to content

Commit 2b766a8

Browse files
committed
deleteDuplicateRows allows for null fields
1 parent 2e54570 commit 2b766a8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/PHPFUI/ORM/Migration.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ protected function alterColumn(string $table, string $field, string $parameters,
279279

280280
/**
281281
* Duplicate rows with the same key values will be deleted
282+
*
283+
* @param array<string> $keys
282284
*/
283285
protected function deleteDuplicateRows(string $table, array $keys) : bool
284286
{
@@ -294,8 +296,16 @@ protected function deleteDuplicateRows(string $table, array $keys) : bool
294296

295297
foreach ($keys as $key)
296298
{
297-
$input[] = $row[$key];
298-
$where .= "{$comma}`{$key}`=?";
299+
// @phpstan-ignore-next-line
300+
if (is_null($row[$key]))
301+
{
302+
$where .= "{$comma}`{$key}` is null";
303+
}
304+
else
305+
{
306+
$input[] = $row[$key];
307+
$where .= "{$comma}`{$key}`=?";
308+
}
299309
$comma = ' and ';
300310
}
301311
$sql = "delete from `{$table}` where {$where} limit {$count}";

0 commit comments

Comments
 (0)