diff --git a/CHANGELOG.md b/CHANGELOG.md index 036d4bc04..a3ea2779f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Bug #561: Fix `ActiveRecordInterface::upsert()` with `$updateProperties = false` (@Tigrov) - Bug #550: Relation query should be created by related class, not primary model class (@batyrmastyr) - Enh #571: Optimize performance of `ActiveRecord::get()` method (@Tigrov) +- Enh #575: Remove check for empty string in `AbstractActiveRecord::markPropertyChanged()` method (@Tigrov) ## 1.0.2 March 11, 2026 diff --git a/src/AbstractActiveRecord.php b/src/AbstractActiveRecord.php index 985f8d90c..511e629cd 100644 --- a/src/AbstractActiveRecord.php +++ b/src/AbstractActiveRecord.php @@ -391,7 +391,7 @@ public function link(string $relationName, ActiveRecordInterface $linkModel, arr public function markPropertyChanged(string $name): void { - if ($this->oldValues !== null && $name !== '') { + if ($this->oldValues !== null) { unset($this->oldValues[$name]); } } diff --git a/tests/ActiveRecordTest.php b/tests/ActiveRecordTest.php index 15f72702f..83d7c0b77 100644 --- a/tests/ActiveRecordTest.php +++ b/tests/ActiveRecordTest.php @@ -1805,6 +1805,16 @@ public function testMarkPropertyChanged(): void $this->assertSame($expectedAffectedRows, $affectedRows); } + public function testMarkPropertyChangedWithEmptyName() + { + $model = new NullValues(); + $model->assignOldValues(['' => 'empty name', 'name' => 'Vasya']); + + $model->markPropertyChanged(''); + + $this->assertSame(['name' => 'Vasya'], $model->oldValues()); + } + public function testResetsIntermediateViaRelationWhenLinkPropertyChanges(): void { $order = OrderWithCustomerProfileViaCustomerRelation::query()->findByPk(1);