Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function getPrimaryKey($asArray = false)
* @param mixed $value
* @throws \yii\base\InvalidCallException when record is not new
* @deprecated since 2.1.0
*/
*/0
public function setPrimaryKey($value)
{
$pk = static::primaryKey()[0];
Expand Down Expand Up @@ -720,7 +720,7 @@ public static function updateAllCounters($counters, $condition = [])
foreach ($primaryKeys as $pk) {
$script = '';
foreach ($counters as $counter => $value) {
$script .= "ctx._source.{$counter} += params.{$counter};\n";
$script .= "ctx._source.{$counter} = (ctx._source.{$counter} == null ? 0 : ctx._source.{$counter}) + params.{$counter};\n";
}
$bulkCommand->addAction(["update" => ["_id" => $pk]], [
'script' => [
Expand Down