Commit 865f6206 authored by doctrine's avatar doctrine

DQL: Fixed lazy property fetching with multiple components

parent 776c47f7
...@@ -716,7 +716,7 @@ class Doctrine_Query extends Doctrine_Access { ...@@ -716,7 +716,7 @@ class Doctrine_Query extends Doctrine_Access {
* @return void * @return void
*/ */
private function parseFrom($str) { private function parseFrom($str) {
foreach(explode(",",trim($str)) as $reference) { foreach(self::bracketExplode(trim($str),",","(",")") as $reference) {
$reference = trim($reference); $reference = trim($reference);
$table = $this->load($reference); $table = $this->load($reference);
} }
......
...@@ -364,6 +364,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -364,6 +364,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->state = Doctrine_Record::STATE_CLEAN; $this->state = Doctrine_Record::STATE_CLEAN;
$this->table->getAttribute(Doctrine::ATTR_LISTENER)->onLoad($this);
return true; return true;
} }
/** /**
...@@ -386,6 +388,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -386,6 +388,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->state = Doctrine_Record::STATE_CLEAN; $this->state = Doctrine_Record::STATE_CLEAN;
$this->modified = array(); $this->modified = array();
$this->table->getAttribute(Doctrine::ATTR_LISTENER)->onLoad($this);
} }
/** /**
* return the factory that created this data access object * return the factory that created this data access object
......
...@@ -7,7 +7,54 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase { ...@@ -7,7 +7,54 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
$this->tables[] = "Forum_Thread"; $this->tables[] = "Forum_Thread";
parent::prepareTables(); 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() { public function testMultipleFetching() {
$count = $this->dbh->count(); $count = $this->dbh->count();
$this->session->getTable('User')->clear(); $this->session->getTable('User')->clear();
...@@ -125,6 +172,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase { ...@@ -125,6 +172,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
} }
$this->assertTrue($f); $this->assertTrue($f);
} }
public function testValidLazyPropertyFetching() { public function testValidLazyPropertyFetching() {
$q = new Doctrine_Query($this->session); $q = new Doctrine_Query($this->session);
$q->from("User-l(name)"); $q->from("User-l(name)");
...@@ -517,5 +565,6 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase { ...@@ -517,5 +565,6 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
//$this->assertTrue(isset($values['max'])); //$this->assertTrue(isset($values['max']));
} }
*/
} }
?> ?>
...@@ -23,7 +23,7 @@ error_reporting(E_ALL); ...@@ -23,7 +23,7 @@ error_reporting(E_ALL);
$test = new GroupTest("Doctrine Framework Unit Tests"); $test = new GroupTest("Doctrine Framework Unit Tests");
//$test->addTestCase(new Sensei_UnitTestCase()); //$test->addTestCase(new Sensei_UnitTestCase());
/**
$test->addTestCase(new Doctrine_RecordTestCase()); $test->addTestCase(new Doctrine_RecordTestCase());
$test->addTestCase(new Doctrine_SessionTestCase()); $test->addTestCase(new Doctrine_SessionTestCase());
...@@ -45,7 +45,7 @@ $test->addTestCase(new Doctrine_ConfigurableTestCase()); ...@@ -45,7 +45,7 @@ $test->addTestCase(new Doctrine_ConfigurableTestCase());
$test->addTestCase(new Doctrine_Collection_OffsetTestCase()); $test->addTestCase(new Doctrine_Collection_OffsetTestCase());
$test->addTestCase(new Doctrine_CollectionTestCase()); $test->addTestCase(new Doctrine_CollectionTestCase());
*/
$test->addTestCase(new Doctrine_QueryTestCase()); $test->addTestCase(new Doctrine_QueryTestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase()); //$test->addTestCase(new Doctrine_Cache_FileTestCase());
......
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