Commit 14399bd1 authored by Bill Schaller's avatar Bill Schaller

Remove select list addition in SQLServer2012Platform::doModifyLimitQuery - determined unnecessary.

parent 80b18c7f
...@@ -122,13 +122,14 @@ class SQLServer2012Platform extends SQLServer2008Platform ...@@ -122,13 +122,14 @@ class SQLServer2012Platform extends SQLServer2008Platform
) { ) {
if (strtoupper(substr($query, 0, 15)) == 'SELECT DISTINCT') { if (strtoupper(substr($query, 0, 15)) == 'SELECT DISTINCT') {
// SQL Server won't let us order by a non-selected column in a DISTINCT query, // SQL Server won't let us order by a non-selected column in a DISTINCT query,
// so we have to do this madness. This says, select 0 as column one, and order // so we have to do this madness. This says, order by the first column in the
// by column one. // result. SQL Server's docs say that a nonordered query's result order is non-
$query = 'SELECT DISTINCT 0,' . substr($query, 15); // deterministic anyway, so this won't do anything that a bunch of update and
// deletes to the table wouldn't do anyway.
$query .= " ORDER BY 1"; $query .= " ORDER BY 1";
} else { } else {
// In another DBMS, we could do ORDER BY 0, but SQL Server gets angry if you use constant expressions in // In another DBMS, we could do ORDER BY 0, but SQL Server gets angry if you
// the order by list. // use constant expressions in the order by list.
$query .= " ORDER BY (SELECT 0)"; $query .= " ORDER BY (SELECT 0)";
} }
} }
......
...@@ -247,7 +247,7 @@ class SQLServer2012PlatformTest extends AbstractSQLServerPlatformTestCase ...@@ -247,7 +247,7 @@ class SQLServer2012PlatformTest extends AbstractSQLServerPlatformTestCase
{ {
$sql = $this->_platform->modifyLimitQuery("SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result", 10); $sql = $this->_platform->modifyLimitQuery("SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result", 10);
$expected = "SELECT DISTINCT 0, id_0 FROM (SELECT k0_.id AS id_0 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result ORDER BY 1 OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY"; $expected = "SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result ORDER BY 1 OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY";
$this->assertEquals($sql, $expected); $this->assertEquals($sql, $expected);
} }
......
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