From 0e8134448cb2f8c7aef15aed292b9be1d31bfd27 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2011 15:46:48 -0400 Subject: [PATCH] object updates fix bug where you try to select an object by an old unique field after changing the field value use "json" as default json field in database vs. data update version to 1.0.3 --- orm/Object.php | 10 +++++++++- orm/_manifest.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) 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"; }