Skip to content

Commit edc09d3

Browse files
committed
Fallback to existing value in remove
1 parent bfb7ed9 commit edc09d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Database/Adapter/SQL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ protected function getOperatorSQL(string $column, Operator $operator, int &$bind
19811981
case Operator::TYPE_ARRAY_REMOVE:
19821982
$bindKey = "op_{$bindIndex}";
19831983
$bindIndex++;
1984-
return "{$quotedColumn} = JSON_REMOVE({$quotedColumn}, JSON_UNQUOTE(JSON_SEARCH({$quotedColumn}, 'one', :$bindKey)))";
1984+
return "{$quotedColumn} = COALESCE(JSON_REMOVE({$quotedColumn}, JSON_UNQUOTE(JSON_SEARCH({$quotedColumn}, 'one', :$bindKey))), {$quotedColumn})";
19851985

19861986
case Operator::TYPE_ARRAY_UNIQUE:
19871987
return "{$quotedColumn} = IFNULL((SELECT JSON_ARRAYAGG(DISTINCT value) FROM JSON_TABLE({$quotedColumn}, '$[*]' COLUMNS(value JSON PATH '$')) AS jt), '[]')";

0 commit comments

Comments
 (0)