Skip to content

Commit

Permalink
Merge pull request #52 from radsystems/3.2/develop
Browse files Browse the repository at this point in the history
Fixes #4420 - ORM belongs_to relationships can now be set to NULL
  • Loading branch information
zeelot committed Jul 26, 2012
2 parents 9b181f6 + b577bae commit 4af8c37
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion classes/kohana/orm.php
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,9 @@ public function set($column, $value)
$this->_related[$column] = $value;

// Update the foreign key of this model
$this->_object[$this->_belongs_to[$column]['foreign_key']] = $value->pk();
$this->_object[$this->_belongs_to[$column]['foreign_key']] = ($value instanceof ORM)
? $value->pk()
: NULL;

$this->_changed[$column] = $this->_belongs_to[$column]['foreign_key'];
}
Expand Down

0 comments on commit 4af8c37

Please sign in to comment.