Skip to content

Commit

Permalink
Merge branch 'bugfix-orm-is-dirty' of https://github.com/tentwofour/i…
Browse files Browse the repository at this point in the history
…diorm into tentwofour-bugfix-orm-is-dirty
  • Loading branch information
treffynnon committed Dec 14, 2016
2 parents b648c49 + 431684f commit 43ec268
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion idiorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,7 @@ protected function _set_orm_property($key, $value = null, $expr = false) {
* object was saved.
*/
public function is_dirty($key) {
return isset($this->_dirty_fields[$key]);
return array_key_exists($key, $this->_dirty_fields);
}

/**
Expand Down
8 changes: 7 additions & 1 deletion test/ORMTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@ public function testIsNew() {
public function testIsDirty() {
$model = ORM::for_table('test')->create();
$this->assertFalse($model->is_dirty('test'));

$model = ORM::for_table('test')->create(array('test' => 'test'));
$this->assertTrue($model->is_dirty('test'));

$model->test = null;
$this->assertTrue($model->is_dirty('test'));

$model->test = '';
$this->assertTrue($model->is_dirty('test'));
}

public function testArrayAccess() {
Expand Down

0 comments on commit 43ec268

Please sign in to comment.