$sql="SELECT {p.*} FROM (SELECT p.* FROM photos p LEFT JOIN photos_tags t ON t.photo_id = p.id WHERE t.tag_id = 65) p LEFT JOIN photos_tags t ON t.photo_id = p.id WHERE p.can_see = -1 AND t.tag_id = 62 LIMIT 200";
$sql='SELECT {p.*} FROM (SELECT p.* FROM photos p LEFT JOIN photos_tags t ON t.photo_id = p.id WHERE t.tag_id = 65) p LEFT JOIN photos_tags t ON t.photo_id = p.id WHERE p.can_see = -1 AND t.tag_id = 62 LIMIT 200';
$query->parseQuery($sql);
$query->parseQuery($sql);
$this->assertEqual($query->from,array("(SELECT p.* FROM photos p LEFT JOIN photos_tags t ON t.photo_id = p.id WHERE t.tag_id = 65) p LEFT JOIN photos_tags t ON t.photo_id = p.id"));
$this->assertEqual($query->getQueryPart('from'),array('(SELECT p.* FROM photos p LEFT JOIN photos_tags t ON t.photo_id = p.id WHERE t.tag_id = 65) p LEFT JOIN photos_tags t ON t.photo_id = p.id'));
$this->assertEqual($query->where,array('p.can_see = -1 AND t.tag_id = 62'));
$this->assertEqual($query->getQueryPart('where'),array('p.can_see = -1 AND t.tag_id = 62'));
@@ -124,13 +146,13 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
...
@@ -124,13 +146,13 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
$coll[5]->Phonenumber[0]->phonenumber;
$coll[5]->Phonenumber[0]->phonenumber;
$this->assertEqual($count,$this->dbh->count());
$this->assertEqual($count,$this->dbh->count());
}
}
publicfunctiontestPrimaryKeySelectForcing()
publicfunctiontestPrimaryKeySelectForcing()
{
{
// forcing the select of primary key fields
// forcing the select of primary key fields
$query=newDoctrine_RawSql($this->connection);
$query=newDoctrine_RawSql($this->connection);
$query->parseQuery("SELECT {entity.name} FROM entity");
$query->parseQuery('SELECT {entity.name} FROM entity');
$coll=$query->execute();
$coll=$query->execute();
...
@@ -143,7 +165,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
...
@@ -143,7 +165,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
{
{
$query=newDoctrine_RawSql($this->connection);
$query=newDoctrine_RawSql($this->connection);
$query->select('{entity.name}')->from('entity');
$query->select('{entity.name}')->from('entity');
$query->addComponent("entity","User");
$query->addComponent('entity','User');
$coll=$query->execute();
$coll=$query->execute();
$this->assertEqual($coll->count(),8);
$this->assertEqual($coll->count(),8);
...
@@ -155,11 +177,11 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
...
@@ -155,11 +177,11 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
publicfunctiontestColumnAggregationInheritance()
publicfunctiontestColumnAggregationInheritance()
{
{
// forcing the select of primary key fields
// forcing the select of primary key fields
$query=newDoctrine_RawSql($this->connection);
$query=newDoctrine_RawSql($this->connection);
$query->parseQuery("SELECT {entity.name} FROM entity");
$query->parseQuery('SELECT {entity.name} FROM entity');
$query->addComponent("entity","User");
$query->addComponent('entity','User');
$coll=$query->execute();
$coll=$query->execute();
$this->assertEqual($coll->count(),8);
$this->assertEqual($coll->count(),8);
...
@@ -174,8 +196,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
...
@@ -174,8 +196,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
$query=newDoctrine_RawSql($this->connection);
$query=newDoctrine_RawSql($this->connection);
$query->parseQuery("SELECT {entity.name} FROM entity ORDER BY entity.name");
$query->parseQuery('SELECT {entity.name} FROM entity ORDER BY entity.name');
$query->addComponent("entity","User");
$query->addComponent('entity','User');
$this->assertEqual($query->getQuery(),"SELECT entity.name AS entity__name, entity.id AS entity__id FROM entity WHERE entity.type = 0 ORDER BY entity.name");
$this->assertEqual($query->getQuery(),"SELECT entity.name AS entity__name, entity.id AS entity__id FROM entity WHERE entity.type = 0 ORDER BY entity.name");
...
@@ -198,6 +220,5 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
...
@@ -198,6 +220,5 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($query->getQuery(),
$this->assertEqual($query->getQuery(),
"SELECT entity.name AS entity__name, entity.id AS entity__id FROM (SELECT entity.name FROM entity WHERE entity.name = 'something') WHERE entity.id = 2 ORDER BY entity.name");
"SELECT entity.name AS entity__name, entity.id AS entity__id FROM (SELECT entity.name FROM entity WHERE entity.name = 'something') WHERE entity.id = 2 ORDER BY entity.name");