Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/Doctrine/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,8 @@ public function getLimitSubquery()

// add driver specific limit clause
$subquery = $this->_conn->modifyLimitSubquery($table, $subquery, $this->_sqlParts['limit'], $this->_sqlParts['offset']);
// apply any outstanding indexes to the subquery before we rebuild the query parts using new Aliases
$subquery = $this->_applyIndexesToQuery($subquery);

$parts = $this->_tokenizer->quoteExplode($subquery, ' ', "'", "'");

Expand Down Expand Up @@ -1586,6 +1588,7 @@ public function getLimitSubquery()
}

$subquery = implode(' ', $parts);

return $subquery;
}

Expand Down Expand Up @@ -2112,7 +2115,7 @@ public function getCountSqlQuery()
. $this->_conn->quoteIdentifier('dctrn_count_query');
}

return $q;
return $this->_applyIndexesToQuery($q);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions lib/Doctrine/Query/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,6 @@ protected function _execute($params)
$query = $this->_view->getSelectSql();
}

$query = $this->_applyIndexesToQuery($query);

// Get prepared SQL params for execution
$params = $this->getInternalParams();

Expand Down Expand Up @@ -2503,8 +2501,7 @@ protected function _applyIndexesToQuery($sql)
}
}
}
// Empty the index part array to prevent us from accidentally appending twice.
$this->_index_parts = [];

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we no longer need this, it was an overkill safety check which never needed to be applied twice.

The ->getSqlQuery method will build and cache the ->_sql property on the Query object, but it will not store the applied indexes in that cached property, meaning it is safe to regenerate and re-apply the index as of when things change.

return $sql;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/RawSql.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function getSqlQuery($params = array())
if ( ! empty($string)) {
array_pop($this->_sqlParts['where']);
}
return $q;
return $this->_applyIndexesToQuery($q);
}

/**
Expand Down Expand Up @@ -326,7 +326,7 @@ public function getCountSqlQuery($params = array())
array_pop($this->_sqlParts['where']);
}

return $q;
return $this->_applyIndexesToQuery($q);
}

/**
Expand Down