Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[DDC-2390] Remove Query dependency from SqlWalker (and all TreeWalker…

…s) and Parser
  • Loading branch information...
commit a9639ae300a838a69cf8ce7a37f664349b73b657 1 parent 0960711
@beberlei beberlei authored
View
6 lib/Doctrine/ORM/Query.php
@@ -193,7 +193,7 @@ public function getSQL()
*/
public function getAST()
{
- $parser = new Parser($this);
+ $parser = new Parser($this->getDQL(), $this->metadata, $this->_em);
return $parser->getAST();
}
@@ -216,7 +216,7 @@ private function _parse()
// Check query cache.
if ( ! ($this->_useQueryCache && ($queryCache = $this->getQueryCacheDriver()))) {
- $parser = new Parser($this);
+ $parser = new Parser($this->getDQL(), $this->metadata, $this->_em);
$this->_parserResult = $parser->parse();
@@ -234,7 +234,7 @@ private function _parse()
}
// Cache miss.
- $parser = new Parser($this);
+ $parser = new Parser($this->getDQL(), $this->metadata, $this->_em);
$this->_parserResult = $parser->parse();
View
23 lib/Doctrine/ORM/Query/Parser.php
@@ -20,6 +20,7 @@
namespace Doctrine\ORM\Query;
use Doctrine\ORM\Query;
+use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadata;
/**
@@ -171,6 +172,11 @@ class Parser
private $identVariableExpressions = array();
/**
+ * @var string
+ */
+ private $dql;
+
+ /**
* Checks if a function is internally defined. Used to prevent overwriting
* of built-in functions through user-defined functions.
*
@@ -192,11 +198,12 @@ static public function isInternalFunction($functionName)
*
* @param Query $query The Query to parse.
*/
- public function __construct(Query $query)
+ public function __construct($dql, MetadataBag $query, EntityManager $entityManager)
{
+ $this->dql = $dql;
$this->query = $query;
- $this->em = $query->getEntityManager();
- $this->lexer = new Lexer($query->getDql());
+ $this->em = $entityManager;
+ $this->lexer = new Lexer($dql);
$this->parserResult = new ParserResult();
}
@@ -360,7 +367,7 @@ public function parse()
// Run any custom tree walkers over the AST
if ($this->customTreeWalkers) {
- $treeWalkerChain = new TreeWalkerChain($this->query, $this->parserResult, $this->queryComponents);
+ $treeWalkerChain = new TreeWalkerChain($this->query, $this->em, $this->parserResult, $this->queryComponents);
foreach ($this->customTreeWalkers as $walker) {
$treeWalkerChain->addTreeWalker($walker);
@@ -384,7 +391,7 @@ public function parse()
}
$outputWalkerClass = $this->customOutputWalker ?: __NAMESPACE__ . '\SqlWalker';
- $outputWalker = new $outputWalkerClass($this->query, $this->parserResult, $this->queryComponents);
+ $outputWalker = new $outputWalkerClass($this->query, $this->em, $this->parserResult, $this->queryComponents);
// Assign an SQL executor to the parser result
$this->parserResult->setSqlExecutor($outputWalker->getExecutor($AST));
@@ -445,7 +452,7 @@ public function syntaxError($expected = '', $token = null)
$message .= ($expected !== '') ? "Expected {$expected}, got " : 'Unexpected ';
$message .= ($this->lexer->lookahead === null) ? 'end of string.' : "'{$token['value']}'";
- throw QueryException::syntaxError($message, QueryException::dqlError($this->query->getDQL()));
+ throw QueryException::syntaxError($message, QueryException::dqlError($this->dql));
}
/**
@@ -468,7 +475,7 @@ public function semanticalError($message = '', $token = null)
$distance = 12;
// Find a position of a final word to display in error string
- $dql = $this->query->getDql();
+ $dql = $this->dql;
$length = strlen($dql);
$pos = $token['position'] + $distance;
$pos = strpos($dql, ' ', ($length > $pos) ? $pos : $length);
@@ -480,7 +487,7 @@ public function semanticalError($message = '', $token = null)
// Building informative message
$message = 'line 0, col ' . $tokenPos . " near '" . $tokenStr . "': Error: " . $message;
- throw QueryException::semanticalError($message, QueryException::dqlError($this->query->getDQL()));
+ throw QueryException::semanticalError($message, QueryException::dqlError($this->dql));
}
/**
View
6 lib/Doctrine/ORM/Query/SqlWalker.php
@@ -170,13 +170,13 @@ class SqlWalker implements TreeWalker
/**
* {@inheritDoc}
*/
- public function __construct($query, $parserResult, array $queryComponents)
+ public function __construct($metadata, $entityManager, $parserResult, array $queryComponents)
{
- $this->query = $query;
+ $this->query = $metadata;
$this->parserResult = $parserResult;
$this->queryComponents = $queryComponents;
$this->rsm = $parserResult->getResultSetMapping();
- $this->em = $query->getEntityManager();
+ $this->em = $entityManager;
$this->conn = $this->em->getConnection();
$this->platform = $this->conn->getDatabasePlatform();
$this->quoteStrategy = $this->em->getConfiguration()->getQuoteStrategy();
View
2  lib/Doctrine/ORM/Query/TreeWalker.php
@@ -34,7 +34,7 @@
* @param \Doctrine\ORM\Query\ParserResult $parserResult The result of the parsing process.
* @param array $queryComponents The query components (symbol table).
*/
- public function __construct($query, $parserResult, array $queryComponents);
+ public function __construct($query, $entityManager, $parserResult, array $queryComponents);
/**
* Returns internal queryComponents array.
View
13 lib/Doctrine/ORM/Query/TreeWalkerAdapter.php
@@ -50,13 +50,19 @@
private $_queryComponents;
/**
+ * @var \Doctrine\ORM\EntityManager
+ */
+ private $entityManager;
+
+ /**
* {@inheritdoc}
*/
- public function __construct($query, $parserResult, array $queryComponents)
+ public function __construct($query, $entityManager, $parserResult, array $queryComponents)
{
$this->_query = $query;
$this->_parserResult = $parserResult;
$this->_queryComponents = $queryComponents;
+ $this->entityManager = $entityManager;
}
/**
@@ -109,6 +115,11 @@ protected function _getParserResult()
return $this->_parserResult;
}
+ protected function getEntityManager()
+ {
+ return $this->entityManager;
+ }
+
/**
* {@inheritdoc}
*/
View
117 lib/Doctrine/ORM/Query/TreeWalkerChain.php
@@ -34,28 +34,28 @@ class TreeWalkerChain implements TreeWalker
*
* @var TreeWalker[]
*/
- private $_walkers = array();
+ private $walkers = array();
/**
* The original Query.
*
* @var \Doctrine\ORM\AbstractQuery
*/
- private $_query;
+ private $query;
/**
* The ParserResult of the original query that was produced by the Parser.
*
* @var \Doctrine\ORM\Query\ParserResult
*/
- private $_parserResult;
+ private $parserResult;
/**
* The query components of the original query (the "symbol table") that was produced by the Parser.
*
* @var array
*/
- private $_queryComponents;
+ private $queryComponents;
/**
* Returns the internal queryComponents array.
@@ -64,7 +64,7 @@ class TreeWalkerChain implements TreeWalker
*/
public function getQueryComponents()
{
- return $this->_queryComponents;
+ return $this->queryComponents;
}
/**
@@ -78,17 +78,18 @@ public function setQueryComponent($dqlAlias, array $queryComponent)
throw QueryException::invalidQueryComponent($dqlAlias);
}
- $this->_queryComponents[$dqlAlias] = $queryComponent;
+ $this->queryComponents[$dqlAlias] = $queryComponent;
}
/**
* {@inheritdoc}
*/
- public function __construct($query, $parserResult, array $queryComponents)
+ public function __construct($metadata, $entityManager, $parserResult, array $queryComponents)
{
- $this->_query = $query;
- $this->_parserResult = $parserResult;
- $this->_queryComponents = $queryComponents;
+ $this->metadata = $metadata;
+ $this->entityManager = $entityManager;
+ $this->parserResult = $parserResult;
+ $this->queryComponents = $queryComponents;
}
/**
@@ -100,7 +101,7 @@ public function __construct($query, $parserResult, array $queryComponents)
*/
public function addTreeWalker($walkerClass)
{
- $this->_walkers[] = new $walkerClass($this->_query, $this->_parserResult, $this->_queryComponents);
+ $this->walkers[] = new $walkerClass($this->metadata, $this->entityManager, $this->parserResult, $this->queryComponents);
}
/**
@@ -108,10 +109,10 @@ public function addTreeWalker($walkerClass)
*/
public function walkSelectStatement(AST\SelectStatement $AST)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkSelectStatement($AST);
- $this->_queryComponents = $walker->getQueryComponents();
+ $this->queryComponents = $walker->getQueryComponents();
}
}
@@ -120,7 +121,7 @@ public function walkSelectStatement(AST\SelectStatement $AST)
*/
public function walkSelectClause($selectClause)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkSelectClause($selectClause);
}
}
@@ -130,7 +131,7 @@ public function walkSelectClause($selectClause)
*/
public function walkFromClause($fromClause)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkFromClause($fromClause);
}
}
@@ -140,7 +141,7 @@ public function walkFromClause($fromClause)
*/
public function walkFunction($function)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkFunction($function);
}
}
@@ -150,7 +151,7 @@ public function walkFunction($function)
*/
public function walkOrderByClause($orderByClause)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkOrderByClause($orderByClause);
}
}
@@ -160,7 +161,7 @@ public function walkOrderByClause($orderByClause)
*/
public function walkOrderByItem($orderByItem)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkOrderByItem($orderByItem);
}
}
@@ -170,7 +171,7 @@ public function walkOrderByItem($orderByItem)
*/
public function walkHavingClause($havingClause)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkHavingClause($havingClause);
}
}
@@ -180,7 +181,7 @@ public function walkHavingClause($havingClause)
*/
public function walkJoin($join)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkJoin($join);
}
}
@@ -190,7 +191,7 @@ public function walkJoin($join)
*/
public function walkSelectExpression($selectExpression)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkSelectExpression($selectExpression);
}
}
@@ -200,7 +201,7 @@ public function walkSelectExpression($selectExpression)
*/
public function walkQuantifiedExpression($qExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkQuantifiedExpression($qExpr);
}
}
@@ -210,7 +211,7 @@ public function walkQuantifiedExpression($qExpr)
*/
public function walkSubselect($subselect)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkSubselect($subselect);
}
}
@@ -220,7 +221,7 @@ public function walkSubselect($subselect)
*/
public function walkSubselectFromClause($subselectFromClause)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkSubselectFromClause($subselectFromClause);
}
}
@@ -230,7 +231,7 @@ public function walkSubselectFromClause($subselectFromClause)
*/
public function walkSimpleSelectClause($simpleSelectClause)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkSimpleSelectClause($simpleSelectClause);
}
}
@@ -240,7 +241,7 @@ public function walkSimpleSelectClause($simpleSelectClause)
*/
public function walkSimpleSelectExpression($simpleSelectExpression)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkSimpleSelectExpression($simpleSelectExpression);
}
}
@@ -250,7 +251,7 @@ public function walkSimpleSelectExpression($simpleSelectExpression)
*/
public function walkAggregateExpression($aggExpression)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkAggregateExpression($aggExpression);
}
}
@@ -260,7 +261,7 @@ public function walkAggregateExpression($aggExpression)
*/
public function walkGroupByClause($groupByClause)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkGroupByClause($groupByClause);
}
}
@@ -270,7 +271,7 @@ public function walkGroupByClause($groupByClause)
*/
public function walkGroupByItem($groupByItem)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkGroupByItem($groupByItem);
}
}
@@ -280,7 +281,7 @@ public function walkGroupByItem($groupByItem)
*/
public function walkUpdateStatement(AST\UpdateStatement $AST)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkUpdateStatement($AST);
}
}
@@ -290,7 +291,7 @@ public function walkUpdateStatement(AST\UpdateStatement $AST)
*/
public function walkDeleteStatement(AST\DeleteStatement $AST)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkDeleteStatement($AST);
}
}
@@ -300,7 +301,7 @@ public function walkDeleteStatement(AST\DeleteStatement $AST)
*/
public function walkDeleteClause(AST\DeleteClause $deleteClause)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkDeleteClause($deleteClause);
}
}
@@ -310,7 +311,7 @@ public function walkDeleteClause(AST\DeleteClause $deleteClause)
*/
public function walkUpdateClause($updateClause)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkUpdateClause($updateClause);
}
}
@@ -320,7 +321,7 @@ public function walkUpdateClause($updateClause)
*/
public function walkUpdateItem($updateItem)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkUpdateItem($updateItem);
}
}
@@ -330,7 +331,7 @@ public function walkUpdateItem($updateItem)
*/
public function walkWhereClause($whereClause)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkWhereClause($whereClause);
}
}
@@ -340,7 +341,7 @@ public function walkWhereClause($whereClause)
*/
public function walkConditionalExpression($condExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkConditionalExpression($condExpr);
}
}
@@ -350,7 +351,7 @@ public function walkConditionalExpression($condExpr)
*/
public function walkConditionalTerm($condTerm)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkConditionalTerm($condTerm);
}
}
@@ -360,7 +361,7 @@ public function walkConditionalTerm($condTerm)
*/
public function walkConditionalFactor($factor)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkConditionalFactor($factor);
}
}
@@ -370,7 +371,7 @@ public function walkConditionalFactor($factor)
*/
public function walkConditionalPrimary($condPrimary)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkConditionalPrimary($condPrimary);
}
}
@@ -380,7 +381,7 @@ public function walkConditionalPrimary($condPrimary)
*/
public function walkExistsExpression($existsExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkExistsExpression($existsExpr);
}
}
@@ -390,7 +391,7 @@ public function walkExistsExpression($existsExpr)
*/
public function walkCollectionMemberExpression($collMemberExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkCollectionMemberExpression($collMemberExpr);
}
}
@@ -400,7 +401,7 @@ public function walkCollectionMemberExpression($collMemberExpr)
*/
public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkEmptyCollectionComparisonExpression($emptyCollCompExpr);
}
}
@@ -410,7 +411,7 @@ public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr)
*/
public function walkNullComparisonExpression($nullCompExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkNullComparisonExpression($nullCompExpr);
}
}
@@ -420,7 +421,7 @@ public function walkNullComparisonExpression($nullCompExpr)
*/
public function walkInExpression($inExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkInExpression($inExpr);
}
}
@@ -430,7 +431,7 @@ public function walkInExpression($inExpr)
*/
function walkInstanceOfExpression($instanceOfExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkInstanceOfExpression($instanceOfExpr);
}
}
@@ -440,7 +441,7 @@ function walkInstanceOfExpression($instanceOfExpr)
*/
public function walkLiteral($literal)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkLiteral($literal);
}
}
@@ -450,7 +451,7 @@ public function walkLiteral($literal)
*/
public function walkBetweenExpression($betweenExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkBetweenExpression($betweenExpr);
}
}
@@ -460,7 +461,7 @@ public function walkBetweenExpression($betweenExpr)
*/
public function walkLikeExpression($likeExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkLikeExpression($likeExpr);
}
}
@@ -470,7 +471,7 @@ public function walkLikeExpression($likeExpr)
*/
public function walkStateFieldPathExpression($stateFieldPathExpression)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkStateFieldPathExpression($stateFieldPathExpression);
}
}
@@ -480,7 +481,7 @@ public function walkStateFieldPathExpression($stateFieldPathExpression)
*/
public function walkComparisonExpression($compExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkComparisonExpression($compExpr);
}
}
@@ -490,7 +491,7 @@ public function walkComparisonExpression($compExpr)
*/
public function walkInputParameter($inputParam)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkInputParameter($inputParam);
}
}
@@ -500,7 +501,7 @@ public function walkInputParameter($inputParam)
*/
public function walkArithmeticExpression($arithmeticExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkArithmeticExpression($arithmeticExpr);
}
}
@@ -510,7 +511,7 @@ public function walkArithmeticExpression($arithmeticExpr)
*/
public function walkArithmeticTerm($term)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkArithmeticTerm($term);
}
}
@@ -520,7 +521,7 @@ public function walkArithmeticTerm($term)
*/
public function walkStringPrimary($stringPrimary)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkStringPrimary($stringPrimary);
}
}
@@ -530,7 +531,7 @@ public function walkStringPrimary($stringPrimary)
*/
public function walkArithmeticFactor($factor)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkArithmeticFactor($factor);
}
}
@@ -540,7 +541,7 @@ public function walkArithmeticFactor($factor)
*/
public function walkSimpleArithmeticExpression($simpleArithmeticExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkSimpleArithmeticExpression($simpleArithmeticExpr);
}
}
@@ -550,7 +551,7 @@ public function walkSimpleArithmeticExpression($simpleArithmeticExpr)
*/
public function walkPathExpression($pathExpr)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkPathExpression($pathExpr);
}
}
@@ -560,7 +561,7 @@ public function walkPathExpression($pathExpr)
*/
public function walkResultVariable($resultVariable)
{
- foreach ($this->_walkers as $walker) {
+ foreach ($this->walkers as $walker) {
$walker->walkResultVariable($resultVariable);
}
}
View
6 lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php
@@ -55,13 +55,13 @@ class CountOutputWalker extends SqlWalker
* @param \Doctrine\ORM\Query\ParserResult $parserResult
* @param array $queryComponents
*/
- public function __construct($query, $parserResult, array $queryComponents)
+ public function __construct($query, $entityManager, $parserResult, array $queryComponents)
{
- $this->platform = $query->getEntityManager()->getConnection()->getDatabasePlatform();
+ $this->platform = $entityManager->getConnection()->getDatabasePlatform();
$this->rsm = $parserResult->getResultSetMapping();
$this->queryComponents = $queryComponents;
- parent::__construct($query, $parserResult, $queryComponents);
+ parent::__construct($query, $entityManager, $parserResult, $queryComponents);
}
/**
View
9 lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
@@ -66,18 +66,19 @@ class LimitSubqueryOutputWalker extends SqlWalker
* @param \Doctrine\ORM\Query\ParserResult $parserResult
* @param array $queryComponents
*/
- public function __construct($query, $parserResult, array $queryComponents)
+ public function __construct($query, $entityManager, $parserResult, array $queryComponents)
{
- $this->platform = $query->getEntityManager()->getConnection()->getDatabasePlatform();
+ $this->platform = $entityManager->getConnection()->getDatabasePlatform();
$this->rsm = $parserResult->getResultSetMapping();
$this->queryComponents = $queryComponents;
// Reset limit and offset
$this->firstResult = $query->getFirstResult();
$this->maxResults = $query->getMaxResults();
- $query->setFirstResult(null)->setMaxResults(null);
+ $query->setFirstResult(null);
+ $query->setMaxResults(null);
- parent::__construct($query, $parserResult, $queryComponents);
+ parent::__construct($query, $entityManager, $parserResult, $queryComponents);
}
/**
View
4 tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php
@@ -92,8 +92,8 @@ public function walkSelectStatement(Query\AST\SelectStatement $selectStatement)
null,
false
);
- $meta1 = $this->_getQuery()->getEntityManager()->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
- $meta = $this->_getQuery()->getEntityManager()->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
+ $meta1 = $this->getEntityManager()->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
+ $meta = $this->getEntityManager()->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
$this->setQueryComponent($identificationVariableDeclaration->rangeVariableDeclaration->aliasIdentificationVariable . 'a',
array(
'metadata' => $meta,
View
9 tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php
@@ -44,15 +44,14 @@ public function assertInvalidDQL($dql, $debug = false)
public function parseDql($dql, $hints = array())
{
- $query = $this->_em->createQuery($dql);
- $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
- $query->setDql($dql);
+ $metadata = new \Doctrine\ORM\Query\MetadataBag;
+ $metadata->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
foreach ($hints as $key => $value) {
- $query->setHint($key, $value);
+ $metadata->setHint($key, $value);
}
- $parser = new \Doctrine\ORM\Query\Parser($query);
+ $parser = new \Doctrine\ORM\Query\Parser($dql, $metadata, $this->_em);
// We do NOT test SQL output here. That only unnecessarily slows down the tests!
$parser->setCustomOutputTreeWalker('Doctrine\Tests\Mocks\MockTreeWalker');
Please sign in to comment.
Something went wrong with that request. Please try again.