Commit 615dcdb8 authored by zYne's avatar zYne

--no commit message

--no commit message
parent ce1002a0
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
abstract class Doctrine_Configurable abstract class Doctrine_Configurable extends Doctrine_Object
{ {
/** /**
* @var array $attributes an array of containing all attributes * @var array $attributes an array of containing all attributes
......
...@@ -946,7 +946,7 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable ...@@ -946,7 +946,7 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
return $array; return $array;
} }
while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) { while ($data = $stmt->fetch(Doctrine::FETCH_ASSOC)) {
$parse = true; $parse = true;
...@@ -965,6 +965,7 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable ...@@ -965,6 +965,7 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
$map = $this->_aliasMap[$cache[$key]['alias']]; $map = $this->_aliasMap[$cache[$key]['alias']];
$table = $map['table']; $table = $map['table'];
$alias = $cache[$key]['alias']; $alias = $cache[$key]['alias'];
$field = $cache[$key]['field'];
$componentName = $map['table']->getComponentName(); $componentName = $map['table']->getComponentName();
if (isset($map['relation'])) { if (isset($map['relation'])) {
...@@ -1039,8 +1040,10 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable ...@@ -1039,8 +1040,10 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
$currData[$alias] = array(); $currData[$alias] = array();
$identifiable[$alias] = null; $identifiable[$alias] = null;
} }
$field = $cache[$key]['field'];
$currData[$alias][$field] = $value;
$currData[$alias][$field] = $table->prepareValue($field, $value);
$index = false; $index = false;
if ($value !== null) { if ($value !== null) {
$identifiable[$alias] = true; $identifiable[$alias] = true;
......
...@@ -53,10 +53,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -53,10 +53,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
* @var string $root root directory * @var string $root root directory
*/ */
protected $_root; protected $_root;
/**
* @var Doctrine_Null $null Doctrine_Null object, used for extremely fast null value checking
*/
protected $_null;
/** /**
* @var array $_integrityActions an array containing all registered integrity actions * @var array $_integrityActions an array containing all registered integrity actions
* used when emulating these actions * used when emulating these actions
...@@ -72,11 +68,8 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -72,11 +68,8 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
private function __construct() private function __construct()
{ {
$this->_root = dirname(__FILE__); $this->_root = dirname(__FILE__);
$this->_null = new Doctrine_Null;
Doctrine_Record_Iterator::initNullObject($this->_null); Doctrine_Object::initNullObject(new Doctrine_Null);
Doctrine_Validator::initNullObject($this->_null);
Doctrine_Object::initNullObject($this->_null);
} }
public function addDeleteAction($componentName, $foreignComponent, $action) public function addDeleteAction($componentName, $foreignComponent, $action)
{ {
...@@ -102,13 +95,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -102,13 +95,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
return $this->_integrityActions[$componentName]['onUpdate']; return $this->_integrityActions[$componentName]['onUpdate'];
} }
/**
* @return Doctrine_Null
*/
final public function getNullObject()
{
return $this->_null;
}
/** /**
* setDefaultAttributes * setDefaultAttributes
* sets default attributes * sets default attributes
......
...@@ -162,8 +162,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ...@@ -162,8 +162,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
// get the column count // get the column count
$count = count($this->_data); $count = count($this->_data);
// clean data array
$this->_data = $this->_filter->cleanData($this->_data); $this->_data = $this->_filter->cleanData($this->_data);
$this->prepareIdentifiers($exists); $this->prepareIdentifiers($exists);
...@@ -625,12 +624,13 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ...@@ -625,12 +624,13 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
} }
$id = array_values($id); $id = array_values($id);
$query = 'SELECT * FROM ' . $this->_table->getOption('tableName') . ' WHERE ' . implode(' = ? AND ', $this->_table->getPrimaryKeys()) . ' = ?'; $records = Doctrine_Query::create()
$stmt = $this->_table->getConnection()->execute($query,$id); ->from($this->_table->getComponentName())
->where(implode(' = ? AND ', $this->_table->getPrimaryKeys()) . ' = ?')
->execute($id);
$this->_data = $stmt->fetch(PDO::FETCH_ASSOC);
if ( ! $this->_data) { if (count($records) === 0) {
throw new Doctrine_Record_Exception('Failed to refresh. Record does not exist.'); throw new Doctrine_Record_Exception('Failed to refresh. Record does not exist.');
} }
...@@ -645,7 +645,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ...@@ -645,7 +645,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$this->_table->getAttribute(Doctrine::ATTR_LISTENER)->onLoad($this); $this->_table->getAttribute(Doctrine::ATTR_LISTENER)->onLoad($this);
return true; return $this;
} }
/** /**
* factoryRefresh * factoryRefresh
...@@ -1049,7 +1049,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ...@@ -1049,7 +1049,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
default: default:
if ($this->_data[$v] instanceof Doctrine_Record) { if ($this->_data[$v] instanceof Doctrine_Record) {
$this->_data[$v] = $this->_data[$v]->getIncremented(); $this->_data[$v] = $this->_data[$v]->getIncremented();
} }
$a[$v] = $this->_data[$v]; $a[$v] = $this->_data[$v];
} }
......
...@@ -111,52 +111,9 @@ class Doctrine_Record_Filter extends Doctrine_Object ...@@ -111,52 +111,9 @@ class Doctrine_Record_Filter extends Doctrine_Object
*/ */
public function cleanData($data) public function cleanData($data)
{ {
$tmp = $data;
$data = array();
foreach ($this->_record->getTable()->getColumnNames() as $name) { foreach ($this->_record->getTable()->getColumnNames() as $name) {
$type = $this->_record->getTable()->getTypeOf($name); if ( ! isset($data[$name])) {
if ( ! isset($tmp[$name])) {
$data[$name] = self::$_null; $data[$name] = self::$_null;
} else {
switch ($type) {
case 'array':
case 'object':
if ($tmp[$name] !== self::$_null) {
if (is_string($tmp[$name])) {
$value = unserialize($tmp[$name]);
if ($value === false) {
throw new Doctrine_Record_Exception('Unserialization of ' . $name . ' failed.');
}
} else {
$value = $tmp[$name];
}
$data[$name] = $value;
}
break;
case 'gzip':
if ($tmp[$name] !== self::$_null) {
$value = gzuncompress($tmp[$name]);
if ($value === false) {
throw new Doctrine_Record_Exception('Uncompressing of ' . $name . ' failed.');
}
$data[$name] = $value;
}
break;
case 'enum':
$data[$name] = $this->_record->getTable()->enumValue($name, $tmp[$name]);
break;
case 'boolean':
$data[$name] = (boolean) $tmp[$name];
break;
default:
$data[$name] = $tmp[$name];
}
} }
} }
return $data; return $data;
......
...@@ -811,20 +811,16 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -811,20 +811,16 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$id = array_values($id); $id = array_values($id);
} }
$query = 'SELECT ' . implode(', ', array_keys($this->columns)) . ' FROM ' . $this->getTableName() $records = Doctrine_Query::create()
. ' WHERE ' . implode(' = ? AND ', $this->primaryKeys) . ' = ?'; ->from($this->getComponentName())
$query = $this->applyInheritance($query); ->where(implode(' = ? AND ', $this->primaryKeys) . ' = ?')
->execute($id);
$params = array_merge($id, array_values($this->options['inheritanceMap'])); if (count($records) === 0) {
$stmt = $this->conn->execute($query, $params);
$this->data = $stmt->fetch(PDO::FETCH_ASSOC);
if ($this->data === false)
return false; return false;
}
return $this->getRecord(); return $records->getFirst();
} }
return false; return false;
} }
...@@ -967,7 +963,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -967,7 +963,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$inheritanceMap = $table->getOption('inheritanceMap'); $inheritanceMap = $table->getOption('inheritanceMap');
$nomatch = false; $nomatch = false;
foreach ($inheritanceMap as $key => $value) { foreach ($inheritanceMap as $key => $value) {
if (!isset($this->data[$key]) || $this->data[$key] != $value) { if ( ! isset($this->data[$key]) || $this->data[$key] !== $value) {
$nomatch = true; $nomatch = true;
break; break;
} }
...@@ -1178,7 +1174,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1178,7 +1174,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/ */
public function prepareValue($field, $value) public function prepareValue($field, $value)
{ {
if ($value === null) { if ($value === null || $value === self::$_null) {
return self::$_null; return self::$_null;
} else { } else {
$type = $this->getTypeOf($field); $type = $this->getTypeOf($field);
...@@ -1211,7 +1207,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1211,7 +1207,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
break; break;
case 'integer': case 'integer':
return (int) $value; return (int) $value;
break; break;
} }
} }
return $value; return $value;
......
...@@ -39,7 +39,7 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase ...@@ -39,7 +39,7 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase
$this->tables = array("EnumTest", "EnumTest2", "EnumTest3"); $this->tables = array("EnumTest", "EnumTest2", "EnumTest3");
parent::prepareTables(); parent::prepareTables();
} }
/**
public function testParameterConversion() public function testParameterConversion()
{ {
$test = new EnumTest(); $test = new EnumTest();
...@@ -97,6 +97,7 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase ...@@ -97,6 +97,7 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase
$this->fail(); $this->fail();
} }
} }
public function testNotEqual() public function testNotEqual()
{ {
try { try {
...@@ -107,7 +108,7 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase ...@@ -107,7 +108,7 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase
$this->fail(); $this->fail();
} }
} }
*/
public function testEnumType() public function testEnumType()
{ {
...@@ -164,13 +165,13 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase ...@@ -164,13 +165,13 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase
$this->conn->exec('DELETE FROM enum_test WHERE id = 1'); $this->conn->exec('DELETE FROM enum_test WHERE id = 1');
$f = false;
try { try {
$enum->refresh(); $enum->refresh();
$this->fail();
} catch(Doctrine_Record_Exception $e) { } catch(Doctrine_Record_Exception $e) {
$f = true; $this->pass();
} }
$this->assertTrue($f);
} }
public function testEnumFetchArray() { public function testEnumFetchArray() {
......
...@@ -70,7 +70,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests'); ...@@ -70,7 +70,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
$test->addTestCase(new Doctrine_Ticket330_TestCase()); $test->addTestCase(new Doctrine_Ticket330_TestCase());
*/ */
/** */ /** */
// Connection drivers (not yet fully tested) // Connection drivers (not yet fully tested)
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase()); $test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase()); $test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
...@@ -182,7 +182,6 @@ $test->addTestCase(new Doctrine_Relation_Parser_TestCase()); ...@@ -182,7 +182,6 @@ $test->addTestCase(new Doctrine_Relation_Parser_TestCase());
// Datatypes // Datatypes
$test->addTestCase(new Doctrine_Enum_TestCase()); $test->addTestCase(new Doctrine_Enum_TestCase());
$test->addTestCase(new Doctrine_Boolean_TestCase()); $test->addTestCase(new Doctrine_Boolean_TestCase());
// Utility components // Utility components
...@@ -190,6 +189,7 @@ $test->addTestCase(new Doctrine_Boolean_TestCase()); ...@@ -190,6 +189,7 @@ $test->addTestCase(new Doctrine_Boolean_TestCase());
//$test->addTestCase(new Doctrine_PessimisticLocking_TestCase()); //$test->addTestCase(new Doctrine_PessimisticLocking_TestCase());
$test->addTestCase(new Doctrine_View_TestCase()); $test->addTestCase(new Doctrine_View_TestCase());
$test->addTestCase(new Doctrine_Validator_TestCase()); $test->addTestCase(new Doctrine_Validator_TestCase());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment