Commit 625dd635 authored by Steve Müller's avatar Steve Müller

Merge pull request #2310 from asgrim/fix-order-of-params-for-migrations

[DB2] Move row number to the end of the field list in query limit/offset modification
parents a500e1ab 2ee02ed3
...@@ -749,7 +749,7 @@ class DB2Platform extends AbstractPlatform ...@@ -749,7 +749,7 @@ class DB2Platform extends AbstractPlatform
$offset = (int) (($offset)?:0); $offset = (int) (($offset)?:0);
// Todo OVER() needs ORDER BY data! // Todo OVER() needs ORDER BY data!
$sql = 'SELECT db22.* FROM (SELECT ROW_NUMBER() OVER() AS DC_ROWNUM, db21.* '. $sql = 'SELECT db22.* FROM (SELECT db21.*, ROW_NUMBER() OVER() AS DC_ROWNUM '.
'FROM (' . $query . ') db21) db22 WHERE db22.DC_ROWNUM BETWEEN ' . ($offset+1) .' AND ' . ($offset+$limit); 'FROM (' . $query . ') db21) db22 WHERE db22.DC_ROWNUM BETWEEN ' . ($offset+1) .' AND ' . ($offset+$limit);
return $sql; return $sql;
......
...@@ -347,21 +347,21 @@ class DB2PlatformTest extends AbstractPlatformTestCase ...@@ -347,21 +347,21 @@ class DB2PlatformTest extends AbstractPlatformTestCase
); );
$this->assertEquals( $this->assertEquals(
'SELECT db22.* FROM (SELECT ROW_NUMBER() OVER() AS DC_ROWNUM, db21.* FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM BETWEEN 1 AND 10', 'SELECT db22.* FROM (SELECT db21.*, ROW_NUMBER() OVER() AS DC_ROWNUM FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM BETWEEN 1 AND 10',
$this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0) $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0)
); );
$this->assertEquals( $this->assertEquals(
'SELECT db22.* FROM (SELECT ROW_NUMBER() OVER() AS DC_ROWNUM, db21.* FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM BETWEEN 1 AND 10', 'SELECT db22.* FROM (SELECT db21.*, ROW_NUMBER() OVER() AS DC_ROWNUM FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM BETWEEN 1 AND 10',
$this->_platform->modifyLimitQuery('SELECT * FROM user', 10) $this->_platform->modifyLimitQuery('SELECT * FROM user', 10)
); );
$this->assertEquals( $this->assertEquals(
'SELECT db22.* FROM (SELECT ROW_NUMBER() OVER() AS DC_ROWNUM, db21.* FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM BETWEEN 6 AND 15', 'SELECT db22.* FROM (SELECT db21.*, ROW_NUMBER() OVER() AS DC_ROWNUM FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM BETWEEN 6 AND 15',
$this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 5) $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 5)
); );
$this->assertEquals( $this->assertEquals(
'SELECT db22.* FROM (SELECT ROW_NUMBER() OVER() AS DC_ROWNUM, db21.* FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM BETWEEN 6 AND 5', 'SELECT db22.* FROM (SELECT db21.*, ROW_NUMBER() OVER() AS DC_ROWNUM FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM BETWEEN 6 AND 5',
$this->_platform->modifyLimitQuery('SELECT * FROM user', 0, 5) $this->_platform->modifyLimitQuery('SELECT * FROM user', 0, 5)
); );
} }
......
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