1
0
mirror of synced 2025-01-18 14:31:40 +03:00

DQL: Fixed lazy property fetching with multiple components

This commit is contained in:
doctrine 2006-05-30 22:14:50 +00:00
parent 776c47f769
commit 865f620658
4 changed files with 56 additions and 3 deletions

View File

@ -716,7 +716,7 @@ class Doctrine_Query extends Doctrine_Access {
* @return void
*/
private function parseFrom($str) {
foreach(explode(",",trim($str)) as $reference) {
foreach(self::bracketExplode(trim($str),",","(",")") as $reference) {
$reference = trim($reference);
$table = $this->load($reference);
}

View File

@ -364,6 +364,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->state = Doctrine_Record::STATE_CLEAN;
$this->table->getAttribute(Doctrine::ATTR_LISTENER)->onLoad($this);
return true;
}
/**
@ -386,6 +388,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->state = Doctrine_Record::STATE_CLEAN;
$this->modified = array();
$this->table->getAttribute(Doctrine::ATTR_LISTENER)->onLoad($this);
}
/**
* return the factory that created this data access object

View File

@ -7,7 +7,54 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
$this->tables[] = "Forum_Thread";
parent::prepareTables();
}
public function testLazyPropertyFetchingWithMultipleColumns() {
$q = new Doctrine_Query($this->session);
$q->from("User-l(name, email_id)");
$users = $q->execute();
$this->assertEqual($users->count(), 8);
$this->assertTrue($users instanceof Doctrine_Collection_Lazy);
$count = count($this->dbh);
$this->assertTrue(is_string($users[0]->name));
$this->assertEqual($count, count($this->dbh));
$count = count($this->dbh);
$this->assertTrue(is_numeric($users[0]->email_id));
$this->assertEqual($count, count($this->dbh));
$users[0]->getTable()->clear();
$q->from("User-b(name, email_id)");
$users = $q->execute();
$this->assertEqual($users->count(), 8);
$this->assertTrue($users instanceof Doctrine_Collection_Batch);
$count = count($this->dbh);
$this->assertTrue(is_string($users[0]->name));
$this->assertEqual($count, count($this->dbh));
$count = count($this->dbh);
$this->assertTrue(is_numeric($users[0]->email_id));
$this->assertEqual($count, count($this->dbh));
$this->assertTrue(is_numeric($users[1]->email_id));
$this->assertEqual($count, count($this->dbh));
$this->assertTrue(is_numeric($users[2]->email_id));
$this->assertEqual($count, count($this->dbh));
$q->from("User-b(name, email_id):Email, User-b(name, email_id).Phonenumber");
$users = $q->execute();
$this->assertEqual($users->count(), 8);
$this->assertTrue($users instanceof Doctrine_Collection_Batch);
$count = count($this->dbh);
$this->assertTrue(is_string($users[0]->name));
$this->assertEqual($count, count($this->dbh));
$count = count($this->dbh);
$this->assertTrue(is_numeric($users[0]->email_id));
$this->assertEqual($count, count($this->dbh));
$this->assertTrue(is_numeric($users[1]->email_id));
$this->assertEqual($count, count($this->dbh));
$this->assertTrue(is_numeric($users[2]->email_id));
$this->assertEqual($count, count($this->dbh));
}
/**
public function testMultipleFetching() {
$count = $this->dbh->count();
$this->session->getTable('User')->clear();
@ -125,6 +172,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
}
$this->assertTrue($f);
}
public function testValidLazyPropertyFetching() {
$q = new Doctrine_Query($this->session);
$q->from("User-l(name)");
@ -517,5 +565,6 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
//$this->assertTrue(isset($values['max']));
}
*/
}
?>

View File

@ -23,7 +23,7 @@ error_reporting(E_ALL);
$test = new GroupTest("Doctrine Framework Unit Tests");
//$test->addTestCase(new Sensei_UnitTestCase());
/**
$test->addTestCase(new Doctrine_RecordTestCase());
$test->addTestCase(new Doctrine_SessionTestCase());
@ -45,7 +45,7 @@ $test->addTestCase(new Doctrine_ConfigurableTestCase());
$test->addTestCase(new Doctrine_Collection_OffsetTestCase());
$test->addTestCase(new Doctrine_CollectionTestCase());
*/
$test->addTestCase(new Doctrine_QueryTestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());