Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fixe Oracle Pagination bug when ordering is present (e.g. Oracle subquery ordering) #645

wants to merge 2 commits into from

4 participants


See for a full description of the problem.



thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

We use Jira to track the state of pull requests and the versions they got
included in.


Closing per new changes: raykolbe@4bafcc5

@raykolbe raykolbe closed this

It's possible to backport this commit to branche 2.3 ? Thank's


@Garfield-fr won't be backported to 2.3: 2.3 is frozen for bugfixes that are non-security related.


OK, I copy some files into my project and patch this. Thank's for your answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 6 deletions.
  1. +8 −6 lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
14 lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
@@ -16,6 +16,7 @@
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\AST\SelectStatement;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
+use Doctrine\DBAL\Platforms\OraclePlatform;
* Wraps the query in order to select root entity IDs for pagination.
@@ -137,13 +138,14 @@ public function walkSelectStatement(SelectStatement $AST)
- // Build the counter query.
+ // Build the counter query
$sql = sprintf('SELECT DISTINCT %s FROM (%s) dctrn_result',
implode(', ', $sqlIdentifier), $innerSql);
- if ($this->platform instanceof PostgreSqlPlatform) {
+ if ($this->platform instanceof PostgreSqlPlatform ||
+ $this->platform instanceof OraclePlatform) {
- $this->getPostgresqlSql($AST, $sqlIdentifier, $innerSql, $sql);
+ $this->preserveSqlOrdering($AST, $sqlIdentifier, $innerSql, $sql);
// Apply the limit and offset.
@@ -161,9 +163,9 @@ public function walkSelectStatement(SelectStatement $AST)
return $sql;
- * Generates new SQL for postgresql if necessary.
+ * Generates new SQL for Postgresql or Oracle if necessary.
* @param SelectStatement $AST
* @param array $sqlIdentifier
@@ -172,7 +174,7 @@ public function walkSelectStatement(SelectStatement $AST)
* @return void
- public function getPostgresqlSql(SelectStatement $AST, array $sqlIdentifier, $innerSql, &$sql)
+ public function preserveSqlOrdering(SelectStatement $AST, array $sqlIdentifier, $innerSql, &$sql)
// For every order by, find out the SQL alias by inspecting the ResultSetMapping.
$sqlOrderColumns = array();
Something went wrong with that request. Please try again.