[#1261] get_key now pulls from $original instead

This is in reference to issue #1261, where Model->get_key() returns
the key from the $attributes instead of from the $original property.
This breaks the functionality of a model with a primary key that may
change, as the SQL generated will be something like:

UPDATE `model` SET `key` = 'new-key' WHERE `key` = 'new-key';

Which won't update the model in the database.
This commit is contained in:
RK
2012-09-24 09:58:20 -04:00
parent 0dc124d342
commit 258169ea00

View File

@@ -544,7 +544,7 @@ abstract class Model {
*/ */
public function get_key() public function get_key()
{ {
return $this->get_attribute(static::$key); return get_array($this->original, static::$key);
} }
/** /**
@@ -721,7 +721,7 @@ abstract class Model {
{ {
if (array_key_exists($key, $this->$source)) return true; if (array_key_exists($key, $this->$source)) return true;
} }
if (method_exists($this, $key)) return true; if (method_exists($this, $key)) return true;
} }