Skip to content
Browse files

DDC-551 - rework walker filtering

  • Loading branch information...
1 parent ad6130b commit b6d776f75de2820a40ad2dd0150ce0c08d75a2c2 @beberlei beberlei committed Dec 11, 2011
Showing with 19 additions and 22 deletions.
  1. +19 −22 lib/Doctrine/ORM/Query/SqlWalker.php
View
41 lib/Doctrine/ORM/Query/SqlWalker.php
@@ -269,7 +269,7 @@ private function _generateClassTableInheritanceJoins($class, $dqlAlias)
}
// Add filters on the root class
- if ('' !== $filterSql = $this->generateFilterConditionSQL($parentClass, $tableAlias)) {
+ if ($filterSql = $this->generateFilterConditionSQL($parentClass, $tableAlias)) {
$sqlParts[] = $filterSql;
}
@@ -853,10 +853,6 @@ public function walkJoinVariableDeclaration($joinVarDecl)
}
}
- // Apply the filters
- if ('' !== $filterExpr = $this->generateFilterConditionSQL($targetClass, $targetTableAlias)) {
- $sql .= ' AND ' . $filterExpr;
- }
} else if ($assoc['type'] == ClassMetadata::MANY_TO_MANY) {
// Join relation table
$joinTable = $assoc['joinTable'];
@@ -920,11 +916,11 @@ public function walkJoinVariableDeclaration($joinVarDecl)
$sql .= $targetTableAlias . '.' . $quotedTargetColumn . ' = ' . $joinTableAlias . '.' . $relationColumn;
}
}
+ }
- // Apply the filters
- if ('' !== $filterExpr = $this->generateFilterConditionSQL($targetClass, $targetTableAlias)) {
- $sql .= ' AND ' . $filterExpr;
- }
+ // Apply the filters
+ if ($filterExpr = $this->generateFilterConditionSQL($targetClass, $targetTableAlias)) {
+ $sql .= ' AND ' . $filterExpr;
}
// Handle WITH clause
@@ -1527,23 +1523,24 @@ public function walkWhereClause($whereClause)
$condSql = null !== $whereClause ? $this->walkConditionalExpression($whereClause->conditionalExpression) : '';
$discrSql = $this->_generateDiscriminatorColumnConditionSql($this->_rootAliases);
- // Apply the filters for all entities in FROM
- $filterClauses = array();
- foreach ($this->_rootAliases as $dqlAlias) {
- $class = $this->_queryComponents[$dqlAlias]['metadata'];
- $tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias);
+ if ($this->_em->hasFilters()) {
+ $filterClauses = array();
+ foreach ($this->_rootAliases as $dqlAlias) {
+ $class = $this->_queryComponents[$dqlAlias]['metadata'];
+ $tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias);
- if ('' !== $filterExpr = $this->generateFilterConditionSQL($class, $tableAlias)) {
- $filterClauses[] = $filterExpr;
+ if ($filterExpr = $this->generateFilterConditionSQL($class, $tableAlias)) {
+ $filterClauses[] = $filterExpr;
+ }
}
- }
- if (count($filterClauses)) {
- if ($condSql) {
- $condSql .= ' AND ';
- }
+ if (count($filterClauses)) {
+ if ($condSql) {
+ $condSql .= ' AND ';
+ }
- $condSql .= implode(' AND ', $filterClauses);
+ $condSql .= implode(' AND ', $filterClauses);
+ }
}
if ($condSql) {

0 comments on commit b6d776f

Please sign in to comment.
Something went wrong with that request. Please try again.