Commit 61790d31 authored by doctrine's avatar doctrine

immediate fetching bug fixed

parent d444bd9a
......@@ -26,7 +26,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/
protected $reference_field;
/**
* @var Doctrine_Relation
* @var Doctrine_Relation the record this collection is related to, if any
*/
protected $relation;
/**
......
......@@ -714,7 +714,7 @@ class Doctrine_DQL_Parser {
$b = array_shift($a);
$b = array_shift($a);
$graph = new Doctrine_DQL_Parser($this->session);
$graph->parseQuery("FROM $b WHERE $where");
$graph->parseQuery("FROM $b-l WHERE $where");
$where = $this->tnames[$root]->getTableName().".id IN (SELECT ".$fk->getLocal()." FROM ".$asf->getTableName()." WHERE ".$fk->getForeign()." IN (".$graph->getQuery()."))";
break;
endswitch;
......
......@@ -3,6 +3,8 @@ require_once("UnitTestCase.class.php");
class Doctrine_DQL_ParserTestCase extends Doctrine_UnitTestCase {
public function testLimit() {
$graph = new Doctrine_DQL_Parser($this->session);
$coll = $graph->query("FROM User LIMIT 3");
$this->assertEqual($graph->getLimit(), 3);
......@@ -141,7 +143,7 @@ class Doctrine_DQL_ParserTestCase extends Doctrine_UnitTestCase {
//$this->clearCache();
$users = $graph->query("FROM User-b, User.Phonenumber");
$users = $graph->query("FROM User-b, User.Phonenumber-b");
$this->assertEqual(trim($graph->getQuery()),
"SELECT entity.id AS User__id, phonenumber.id AS Phonenumber__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0)");
......@@ -157,13 +159,13 @@ class Doctrine_DQL_ParserTestCase extends Doctrine_UnitTestCase {
$users = $graph->query("FROM User-b, User.Email");
$users = $graph->query("FROM User-b, User.Email-b");
$this->assertEqual(trim($graph->getQuery()),
"SELECT entity.id AS User__id, email.id AS Email__id FROM entity, email WHERE (entity.email_id = email.id) AND (entity.type = 0)");
$this->assertEqual($users->count(),8);
$users = $graph->query("FROM Email WHERE Email.address LIKE '%@example%'");
$users = $graph->query("FROM Email-b WHERE Email.address LIKE '%@example%'");
$this->assertEqual($graph->getQuery(),
"SELECT email.id AS Email__id FROM email WHERE (email.address LIKE '%@example%')");
$this->assertEqual($users->count(),8);
......@@ -184,7 +186,6 @@ class Doctrine_DQL_ParserTestCase extends Doctrine_UnitTestCase {
"SELECT entity.id AS User__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (phonenumber.phonenumber REGEXP '[123]') AND (entity.type = 0)");
$this->assertEqual($users->count(),8);
$users = $graph->query("FROM User-b WHERE User.Group.name = 'Action Actors'");
$this->assertEqual(trim($graph->getQuery()),
"SELECT entity.id AS User__id FROM entity WHERE (entity.id IN (SELECT user_id FROM groupuser WHERE group_id IN (SELECT entity.id AS Group__id FROM entity WHERE (entity.name = 'Action Actors') AND (entity.type = 1)))) AND (entity.type = 0)");
......
......@@ -37,7 +37,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$this->manager = Doctrine_Manager::getInstance();
$this->manager->setAttribute(Doctrine::ATTR_CACHE, Doctrine::CACHE_NONE);
$this->manager->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_IMMEDIATE);
if($this->manager->count() > 0) {
$this->session = $this->manager->getSession(0);
$this->session->clear();
......
......@@ -3,7 +3,7 @@ class Entity extends Doctrine_Record {
public function setUp() {
$this->ownsOne("Email","Entity.email_id");
$this->ownsMany("Phonenumber","Phonenumber.entity_id");
$this->setAttribute(Doctrine::ATTR_FETCHMODE,Doctrine::FETCH_BATCH);
}
public function setTableDefinition() {
$this->hasColumn("name","string",50);
......
......@@ -47,6 +47,7 @@ $test->addTestCase(new Doctrine_DQL_ParserTestCase());
$test->addTestCase(new Doctrine_CollectionTestCase());
$test->addTestCase(new Doctrine_ConfigurableTestCase());
$test->addTestCase(new Sensei_UnitTestCase());
......
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