1
0
mirror of synced 2025-01-20 23:41:39 +03:00
This commit is contained in:
zYne 2007-07-05 23:47:48 +00:00
parent 3d736d32b4
commit dbd49e9310
9 changed files with 31 additions and 25 deletions

View File

@ -82,6 +82,8 @@ class Doctrine_Hook
} else {
throw new Doctrine_Exception('Constructor argument should be either Doctrine_Query object or valid DQL query');
}
$this->query->getQuery();
}
/**
* getQuery
@ -130,17 +132,16 @@ class Doctrine_Hook
if (count($e) == 2) {
list($alias, $column) = $e;
/**
$tableAlias = $this->query->getTableAlias($alias);
$map = $this->query->getAliasDeclaration($alias);
$table = $map['table'];
if ( ! $table) {
throw new Doctrine_Exception('Unknown table alias ' . $tableAlias);
throw new Doctrine_Exception('Unknown alias ' . $alias);
}
if ($def = $table->getDefinitionOf($column)) {
*/
$def[0] = gettype($value);
if (isset($this->typeParsers[$def[0]])) {
$name = $this->typeParsers[$def[0]];
@ -150,7 +151,7 @@ class Doctrine_Hook
$parser->parse($alias, $column, $value);
$this->query->addWhere($parser->getCondition(), $parser->getParams());
//}
}
}
}
@ -182,15 +183,13 @@ class Doctrine_Hook
if (count($e) == 2) {
list($alias, $column) = $e;
/**
$tableAlias = $this->query->getTableAlias($alias);
$map = $this->query->getAliasDeclaration($alias);
$table = $map['table'];
if ($def = $table->getDefinitionOf($column)) {
*/
$this->query->addOrderBy($alias . '.' . $column . ' ' . $order);
//}
}
}
}
return true;

View File

@ -1091,6 +1091,9 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$a = array();
foreach ($this as $column => $value) {
if ($value === self::$_null) {
$value = null;
}
$a[$column] = $value;
}
if ($this->_table->getIdentifierType() == Doctrine::IDENTIFIER_AUTOINC) {

View File

@ -115,8 +115,8 @@ class Doctrine_Hook_TestCase extends Doctrine_UnitTestCase
$a['where'] = array('u.unknown' => 'Jack Daniels');
$hook->hookWhere($a['where']);
$this->assertEqual($hook->getQuery()->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)');
$this->assertEqual($hook->getQuery()->getSql(), 'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)');
}
public function testEqualParserUsesEqualOperator()

View File

@ -43,6 +43,6 @@ class Doctrine_NewCore_TestCase extends Doctrine_UnitTestCase
$q->load('u.Phonenumber p', false);
$this->assertEqual($q->getQueryPart('from'), array('entity e', 'LEFT JOIN phonenumber p ON e.id = p.entity_id'));
$this->assertEqual($q->getQueryPart('from'), array('entity e', 'p' => 'LEFT JOIN phonenumber p ON e.id = p.entity_id'));
}
}

View File

@ -42,13 +42,13 @@ class Doctrine_Query_ComponentAlias_TestCase extends Doctrine_UnitTestCase
$users = $q->execute();
$count = count($this->dbh);
$count = count($this->conn);
$this->assertEqual($users->count(), 8);
$this->assertTrue($users[0]->Phonenumber instanceof Doctrine_Collection);
$this->assertEqual($q->getQuery(),
"SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)");
$this->assertEqual($count, count($this->dbh));
$this->assertEqual($count, count($this->conn));
}
public function testQueryWithNestedAliases()
@ -60,13 +60,13 @@ class Doctrine_Query_ComponentAlias_TestCase extends Doctrine_UnitTestCase
$users = $q->execute();
$count = count($this->dbh);
$count = count($this->conn);
$this->assertEqual($users->count(), 8);
$this->assertTrue($users[0]->Phonenumber instanceof Doctrine_Collection);
$this->assertEqual($q->getQuery(),
"SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN groupuser g ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id LEFT JOIN phonenumber p ON e2.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
$this->assertEqual(($count + 1), count($this->dbh));
$this->assertEqual(($count + 1), count($this->conn));
}
public function testQueryWithNestedAliasesAndArrayFetching()
{
@ -77,7 +77,7 @@ class Doctrine_Query_ComponentAlias_TestCase extends Doctrine_UnitTestCase
$users = $q->execute(array(), Doctrine::FETCH_ARRAY);
$count = count($this->dbh);
$count = count($this->conn);
$this->assertEqual(count($users), 8);
$this->assertEqual(count($users[7]['Group']), 0);
@ -93,7 +93,7 @@ class Doctrine_Query_ComponentAlias_TestCase extends Doctrine_UnitTestCase
$users = $q->execute();
$count = count($this->dbh);
$count = count($this->conn);
$this->assertTrue($users[0]->Phonenumber instanceof Doctrine_Collection);
@ -104,7 +104,7 @@ class Doctrine_Query_ComponentAlias_TestCase extends Doctrine_UnitTestCase
$this->assertEqual(count($users[0]['Group'][0]['Phonenumber']), 1);
$this->assertEqual(count($users[1]['Group']), 0);
$this->assertEqual($count, count($this->dbh));
$this->assertEqual($count, count($this->conn));
}
public function testQueryWithMultipleNestedAliasesAndArrayFetching()

View File

@ -62,7 +62,7 @@ class Doctrine_Record_ZeroValues_TestCase extends Doctrine_UnitTestCase
$q->from('ZeroValueTest');
$users = $q->execute(array(), Doctrine::FETCH_ARRAY);
$this->assertIdentical($users[0]['is_super_admin'], '0');
$this->assertIdentical($users[0]['is_super_admin'], false);
// check for aggregate bug
$this->assertTrue( ! isset($users[0][0]));
}

View File

@ -117,6 +117,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$this->assertTrue(is_array($a));
$this->assertTrue(array_key_exists('name', $a));
$this->assertEqual($a['name'], null);
$this->assertTrue(array_key_exists('id', $a));
$this->assertEqual($a['id'], null);

View File

@ -100,7 +100,7 @@ class Doctrine_Ticket364_TestCase extends Doctrine_UnitTestCase {
$q = new Doctrine_Query();
$coll = $q->from('NestReference')->execute(array(), Doctrine::FETCH_ARRAY);
$this->assertEqual(count($coll), 2);
$this->assertEqual(count($coll), 1);
}
}

View File

@ -70,7 +70,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
$test->addTestCase(new Doctrine_Ticket330_TestCase());
*/
/** */
/** */
// Connection drivers (not yet fully tested)
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
@ -155,7 +155,9 @@ $test->addTestCase(new Doctrine_Access_TestCase());
//$test->addTestCase(new Doctrine_Configurable_TestCase());
$test->addTestCase(new Doctrine_Manager_TestCase());
$test->addTestCase(new Doctrine_Connection_TestCase());
$test->addTestCase(new Doctrine_Table_TestCase());
@ -319,9 +321,9 @@ $test->addTestCase(new Doctrine_Cache_Sqlite_TestCase());
$test->addTestCase(new Doctrine_Record_SaveBlankRecord_TestCase());
/**
$test->addTestCase(new Doctrine_Template_TestCase());
*/
/** */
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
//$test->addTestCase(new Doctrine_AuditLog_TestCase());