[DBAL-48] Doctrine\DBAL\Platforms\MsSqlPlatform Incorrect Offset Limit Sql Created: 04/Sep/10 Updated: 14/Nov/10 Resolved: 14/Nov/10
|Reporter:||Scott Connelly||Assignee:||Juozas Kaziukenas|
The way the offset query is constructed (line 473) it always pulls the top records from the query even when and offset is present, so if you have an offset of 0 and limit of 10 you get the first 10 records. When you change the offset to 5 you still get the first 10 records from the original query. This issue was also in the 1.2 driver code.
This is basically what gets created when an offset is present with a limit of 10 and an offset of 5 :
The fix is to reconstruct the query to remove the outer_tbl SELECT TOP and make it something like the following:
|Comment by Juozas Kaziukenas [ 14/Nov/10 ]|
This is fixed in current master https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php#L555
Unless this ticket is referring to Doctrine 1