diff --git a/orm/Object.php b/orm/Object.php index 29b7a42..de3845c 100644 --- a/orm/Object.php +++ b/orm/Object.php @@ -341,6 +341,9 @@ protected static function _getMultiple(array $ids) */ protected static function _getSingle($column, $value) { + $initial_column = $column; + $initial_value = $value; + $class = get_called_class(); $definition = self::getDefinition($class); @@ -381,6 +384,11 @@ protected static function _getSingle($column, $value) return null; } + // fix bug where old items are not removed from cache if the value of the column changes + if ($object->$initial_column != $initial_value) { + return null; + } + return $object; } @@ -417,7 +425,7 @@ public function json($db_field, $json_key = self::JSON_GET, $value = self::JSON_ if (!$this->_propertyExists($original_field)) { $value = $json_key; $json_key = $db_field; - $db_field = 'data'; + $db_field = 'json'; } if (!$this->_propertyExists($db_field) || ($original_field != $db_field && $original_value !== self::JSON_GET)) { diff --git a/orm/_manifest.php b/orm/_manifest.php index f0860c7..91997a8 100644 --- a/orm/_manifest.php +++ b/orm/_manifest.php @@ -10,7 +10,7 @@ */ class Orm extends Manifest { - const VERSION = "1.0.2"; + const VERSION = "1.0.3"; protected $_dependencies = array('Database', 'Cache'); protected $_instructions = "Check out http://sonicframework.com/tutorial/orm for help getting started"; }