Commit 62779913 authored by romanb's avatar romanb

Started to reenable query language recognition tests.

parent a38a1f51
...@@ -124,7 +124,7 @@ abstract class AbstractResult ...@@ -124,7 +124,7 @@ abstract class AbstractResult
public function getQueryComponent($componentAlias) public function getQueryComponent($componentAlias)
{ {
if ( ! isset($this->_queryComponents[$componentAlias])) { if ( ! isset($this->_queryComponents[$componentAlias])) {
throw new Doctrine_ORM_Query_Exception('Unknown query component ' . $componentAlias); throw new \Doctrine\Common\DoctrineException('Unknown query component ' . $componentAlias);
} }
return $this->_queryComponents[$componentAlias]; return $this->_queryComponents[$componentAlias];
......
...@@ -1139,7 +1139,7 @@ class Parser ...@@ -1139,7 +1139,7 @@ class Parser
default: default:
$this->syntaxError(); $this->syntaxError();
} }
throw new Doctrine_Exception("Not yet implemented."); throw new QueryException("Not yet implemented.");
//TODO... //TODO...
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
namespace Doctrine\ORM\Query; namespace Doctrine\ORM\Query;
use Doctrine\ORM\Query\AST; use Doctrine\ORM\Query\AST;
use Doctrine\Common\DoctrineException;
/** /**
* The SqlWalker walks over an AST that represents a DQL query and constructs * The SqlWalker walks over an AST that represents a DQL query and constructs
...@@ -379,9 +380,9 @@ class SqlWalker ...@@ -379,9 +380,9 @@ class SqlWalker
$sqlTableAlias = $this->_dqlToSqlAliasMap[$dqlAlias]; $sqlTableAlias = $this->_dqlToSqlAliasMap[$dqlAlias];
$sql .= $sqlTableAlias . '.' . $class->getColumnName($fieldName); $sql .= $sqlTableAlias . '.' . $class->getColumnName($fieldName);
} else if ($pathExpr->isSimpleStateFieldAssociationPathExpression()) { } else if ($pathExpr->isSimpleStateFieldAssociationPathExpression()) {
throw new Doctrine_Exception("Not yet implemented."); throw new DoctrineException("Not yet implemented.");
} else { } else {
throw new Doctrine_ORM_Query_Exception("Encountered invalid PathExpression during SQL construction."); throw new DoctrineException("Encountered invalid PathExpression during SQL construction.");
} }
return $sql; return $sql;
} }
......
...@@ -21,9 +21,9 @@ class AllTests ...@@ -21,9 +21,9 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\ORM\Query\IdentifierRecognitionTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Query\IdentifierRecognitionTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Query\SelectSqlGenerationTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Query\SelectSqlGenerationTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Query\LanguageRecognitionTest');
/* /*
$suite->addTestSuite('Doctrine\Tests\ORM\Query\LanguageRecognitionTest');
$suite->addTestSuite('Orm_Query_ScannerTest'); $suite->addTestSuite('Orm_Query_ScannerTest');
$suite->addTestSuite('Orm_Query_DqlGenerationTest'); $suite->addTestSuite('Orm_Query_DqlGenerationTest');
$suite->addTestSuite('Orm_Query_DeleteSqlGenerationTest'); $suite->addTestSuite('Orm_Query_DeleteSqlGenerationTest');
......
...@@ -15,10 +15,9 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -15,10 +15,9 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
public function assertValidDql($dql, $debug = false) public function assertValidDql($dql, $debug = false)
{ {
try { try {
$entityManager = $this->_em; $query = $this->_em->createQuery($dql);
$query = $entityManager->createQuery($dql);
$parserResult = $query->parse(); $parserResult = $query->parse();
} catch (Doctrine_Exception $e) { } catch (\Exception $e) {
if ($debug) { if ($debug) {
echo $e->getTraceAsString() . PHP_EOL; echo $e->getTraceAsString() . PHP_EOL;
} }
...@@ -29,13 +28,12 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -29,13 +28,12 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
public function assertInvalidDql($dql, $debug = false) public function assertInvalidDql($dql, $debug = false)
{ {
try { try {
$entityManager = $this->_em; $query = $this->_em->createQuery($dql);
$query = $entityManager->createQuery($dql);
$query->setDql($dql); $query->setDql($dql);
$parserResult = $query->parse(); $parserResult = $query->parse();
$this->fail('No syntax errors were detected, when syntax errors were expected'); $this->fail('No syntax errors were detected, when syntax errors were expected');
} catch (Doctrine_Exception $e) { } catch (\Exception $e) {
//echo $e->getMessage() . PHP_EOL; //echo $e->getMessage() . PHP_EOL;
if ($debug) { if ($debug) {
echo $e->getMessage() . PHP_EOL; echo $e->getMessage() . PHP_EOL;
...@@ -50,13 +48,6 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -50,13 +48,6 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
$this->assertInvalidDql(''); $this->assertInvalidDql('');
} }
public function testPlainFromClauseWithoutAlias()
{
$this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser');
$this->assertValidDql('SELECT id FROM Doctrine\Tests\Models\CMS\CmsUser');
}
public function testPlainFromClauseWithAlias() public function testPlainFromClauseWithAlias()
{ {
$this->assertValidDql('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u'); $this->assertValidDql('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u');
...@@ -64,12 +55,12 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -64,12 +55,12 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
public function testSelectSingleComponentWithAsterisk() public function testSelectSingleComponentWithAsterisk()
{ {
$this->assertValidDql('SELECT u.* FROM Doctrine\Tests\Models\CMS\CmsUser u'); $this->assertValidDql('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u');
} }
public function testInvalidSelectSingleComponentWithAsterisk() public function testInvalidSelectSingleComponentWithAsterisk()
{ {
$this->assertInvalidDql('SELECT p.* FROM Doctrine\Tests\Models\CMS\CmsUser u'); $this->assertInvalidDql('SELECT p FROM Doctrine\Tests\Models\CMS\CmsUser u');
} }
public function testSelectSingleComponentWithMultipleColumns() public function testSelectSingleComponentWithMultipleColumns()
...@@ -79,7 +70,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -79,7 +70,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
public function testSelectMultipleComponentsWithAsterisk() public function testSelectMultipleComponentsWithAsterisk()
{ {
$this->assertValidDql('SELECT u.*, p.* FROM Doctrine\Tests\Models\CMS\CmsUser u, u.phonenumbers p'); $this->assertValidDql('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p');
} }
public function testSelectDistinctIsSupported() public function testSelectDistinctIsSupported()
...@@ -96,30 +87,30 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -96,30 +87,30 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
{ {
$this->assertValidDql('SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u'); $this->assertValidDql('SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u');
} }
/*
public function testFunctionalExpressionsSupportedInWherePart() public function testFunctionalExpressionsSupportedInWherePart()
{ {
$this->assertValidDql("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'"); $this->assertValidDql("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'");
} }
*/
public function testArithmeticExpressionsSupportedInWherePart() public function testArithmeticExpressionsSupportedInWherePart()
{ {
$this->assertValidDql('SELECT u.* FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000'); $this->assertValidDql('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000');
} }
/*
public function testInExpressionSupportedInWherePart() public function testInExpressionSupportedInWherePart()
{ {
$this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser WHERE CmsUser.id IN (1, 2)'); $this->assertValidDql('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)');
} }
public function testNotInExpressionSupportedInWherePart() public function testNotInExpressionSupportedInWherePart()
{ {
$this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)'); $this->assertValidDql('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)');
} }
*/
public function testExistsExpressionSupportedInWherePart() /*public function testExistsExpressionSupportedInWherePart()
{ {
$this->assertValidDql('SELECT u.* FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.user_id FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user_id = u.id)'); $this->assertValidDql('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.user_id FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user_id = u.id)');
} }
public function testNotExistsExpressionSupportedInWherePart() public function testNotExistsExpressionSupportedInWherePart()
...@@ -261,7 +252,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -261,7 +252,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
public function testOrderByWithFunctionExpression() public function testOrderByWithFunctionExpression()
{ {
$this->assertValidDql('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY COALESCE(u.id, u.name) DESC'); $this->assertValidDql('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY COALESCE(u.id, u.name) DESC');
} }*/
/* /*
public function testSubselectInInExpression() public function testSubselectInInExpression()
{ {
...@@ -273,7 +264,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -273,7 +264,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
// Semantical error: Unknown query component u (probably in subselect) // Semantical error: Unknown query component u (probably in subselect)
$this->assertValidDql("SELECT u.name, (SELECT COUNT(p.phonenumber) FROM CmsPhonenumber p WHERE p.user_id = u.id) pcount FROM CmsUser u WHERE u.name = 'zYne' LIMIT 1"); $this->assertValidDql("SELECT u.name, (SELECT COUNT(p.phonenumber) FROM CmsPhonenumber p WHERE p.user_id = u.id) pcount FROM CmsUser u WHERE u.name = 'zYne' LIMIT 1");
} }
*/ *//*
public function testPositionalInputParameter() public function testPositionalInputParameter()
{ {
$this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?'); $this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?');
...@@ -282,7 +273,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -282,7 +273,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
public function testNamedInputParameter() public function testNamedInputParameter()
{ {
$this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :id'); $this->assertValidDql('SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :id');
} }*/
/* /*
public function testCustomJoinsAndWithKeywordSupported() public function testCustomJoinsAndWithKeywordSupported()
{ {
...@@ -290,7 +281,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -290,7 +281,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
$this->assertValidDql('SELECT c.*, c2.*, d.* FROM Record_Country c INNER JOIN c.City c2 WITH c2.id = 2 WHERE c.id = 1'); $this->assertValidDql('SELECT c.*, c2.*, d.* FROM Record_Country c INNER JOIN c.City c2 WITH c2.id = 2 WHERE c.id = 1');
} }
*/ */
/*
public function testJoinConditionsSupported() public function testJoinConditionsSupported()
{ {
$this->assertValidDql("SELECT u.name, p.* FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p ON p.phonenumber = '123 123'"); $this->assertValidDql("SELECT u.name, p.* FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p ON p.phonenumber = '123 123'");
...@@ -320,7 +311,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -320,7 +311,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
{ {
$this->assertValidDql("SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'"); $this->assertValidDql("SELECT * FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'");
} }
*/
/* public function testAllExpressionWithCorrelatedSubquery() /* public function testAllExpressionWithCorrelatedSubquery()
{ {
// We need existant classes here, otherwise semantical will always fail // We need existant classes here, otherwise semantical will always fail
...@@ -338,7 +329,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -338,7 +329,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
// We need existant classes here, otherwise semantical will always fail // We need existant classes here, otherwise semantical will always fail
$this->assertValidDql('SELECT * FROM Employee e WHERE e.salary > SOME (SELECT m.salary FROM Manager m WHERE m.department = e.department)'); $this->assertValidDql('SELECT * FROM Employee e WHERE e.salary > SOME (SELECT m.salary FROM Manager m WHERE m.department = e.department)');
} }
*/ *//*
public function testLikeExpression() public function testLikeExpression()
{ {
$this->assertValidDql("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z%'"); $this->assertValidDql("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z%'");
...@@ -353,7 +344,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -353,7 +344,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
{ {
$this->assertValidDql("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z|%' ESCAPE '|'"); $this->assertValidDql("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z|%' ESCAPE '|'");
} }
*/
/** /**
* TODO: Hydration can't deal with this currently but it should be allowed. * TODO: Hydration can't deal with this currently but it should be allowed.
* Also, generated SQL looks like: "... FROM cms_user, cms_article ..." which * Also, generated SQL looks like: "... FROM cms_user, cms_article ..." which
...@@ -362,7 +353,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -362,7 +353,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
* The main use case for this generalized style of join is when a join condition * The main use case for this generalized style of join is when a join condition
* does not involve a foreign key relationship that is mapped to an entity relationship. * does not involve a foreign key relationship that is mapped to an entity relationship.
*/ */
public function testImplicitJoinWithCartesianProductAndConditionInWhere() /* public function testImplicitJoinWithCartesianProductAndConditionInWhere()
{ {
$this->assertValidDql("SELECT u.*, a.* FROM Doctrine\Tests\Models\CMS\CmsUser u, CmsArticle a WHERE u.name = a.topic"); $this->assertValidDql("SELECT u.*, a.* FROM Doctrine\Tests\Models\CMS\CmsUser u, CmsArticle a WHERE u.name = a.topic");
} }
...@@ -395,5 +386,5 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase ...@@ -395,5 +386,5 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
// Currently UNDEFINED OFFSET error // Currently UNDEFINED OFFSET error
//$this->assertInvalidDql("SELECT * FROM CmsUser.articles.comments"); //$this->assertInvalidDql("SELECT * FROM CmsUser.articles.comments");
} }*/
} }
\ No newline at end of file
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