This commit is contained in:
2023-08-17 17:24:46 +08:00
parent 77648f3878
commit c718e852dd
+6 -3
View File
@@ -508,13 +508,16 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
/** /**
* @return array<array, array> * @return array<array, array>
* @throws Exception
*/ */
private function diff(): array private function diff(): array
{ {
$changes = \array_diff_assoc($this->_attributes, $this->_oldAttributes); $changes = \array_diff_assoc($this->_attributes, $this->_oldAttributes);
if ($this->hasPrimaryValue()) {
$condition = \array_intersect_assoc($this->_oldAttributes, $this->_attributes); $condition = [$this->getPrimary() => $this->getPrimaryValue()];
} else {
$condition = \array_intersect_assoc($this->_oldAttributes, $this->_attributes);
}
return [$changes, $condition]; return [$changes, $condition];
} }