Skip to content

Commit

Permalink
object updates
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ccampbell committed Jun 26, 2011
1 parent 3eb7a2f commit 0e81344
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion orm/Object.php
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion orm/_manifest.php
Expand Up @@ -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";
}

0 comments on commit 0e81344

Please sign in to comment.