Fixed doModifyLimitQuery for SQLServerPlatform #249

merged 1 commit into from Jan 20, 2013


None yet

3 participants


It seems that there is a problem in SQLServerPlatform doModifyLimitQuery method.
I can't use Doctrine ORM Paginator because of wrong position of DISTINCT statement in final limit subquery, here is the exception message I'm getting.
SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near the keyword 'DISTINCT'.

My proposition is to change doModifyLimitQuery result from:

SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY username DESC) AS doctrine_rownum, * FROM user) ...


SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY username DESC) AS doctrine_rownum FROM user) ...



thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:


@beberlei this PR works fine with simple Doctrine Paginator and it fix first point from this list (second point seems to be already done), I can also check those 2 other points and eventually think about some solution if you want.


@norzechowicz thanks, help is very much appreciated with SQL Server, we don't have a core member that is using it in production and could always use somebody that offers some time for maintaining the complicated parts :-)

@beberlei beberlei merged commit f3374cb into doctrine:master Jan 20, 2013

1 check passed

Details default The Travis build passed
@norzechowicz norzechowicz deleted the norzechowicz:sqlserver-platform branch Jan 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment