Skip to content

Commit 0d45638

Browse files
committed
Update ActiveRecord.php
1 parent 0b6efc3 commit 0d45638

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/ActiveRecord.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,21 @@ public function getRowProperties(): array
172172
return $props;
173173
}
174174

175+
/**
176+
* Получение состояния сохраняемых полей.
177+
* @return array
178+
*/
179+
public function getState(): array
180+
{
181+
$state = static::getDb()->identityMapGetState($this, static::primaryKey());
182+
foreach ($state as $name => &$value) {
183+
if (!in_array($name, static::columns())) {
184+
unset($state[$name]);
185+
}
186+
}
187+
return $state;
188+
}
189+
175190
/**
176191
* Получение маппинга измененных свойств записи.
177192
* @return array
@@ -183,7 +198,8 @@ public function getUpdatedProperties(): array
183198
if (empty($this->$pk)) {
184199
return $props;
185200
} else {
186-
$state = static::getDb()->identityMapGetState($this, $pk);
201+
// $state = static::getDb()->identityMapGetState($this, $pk);
202+
$state = $this->getState();
187203
// return array_diff($props, $state ?? []);
188204
return array_merge(
189205
array_fill_keys(array_keys(array_diff($state ?? [], $props)), null),

0 commit comments

Comments
 (0)