jeremyevans/sequel — Issue #389: SQL Server adapter generates incorrect query if limit() is used
Author: yasuyuki
Created: 2011-10-20 05:32:14+00:00
State: open

With SQL Server, run

DB[:table].select(:id, :name).limit(10, 20).order(:id, :name)

, then generates sql (line breakes are added)

SELECT
TOP(20) *
FROM
(
SELECT
([ID], [NAME])
, ROW_NUMBER() OVER(ORDER BY ([ID], [NAME])) AS [X_SEQUEL_ROW_NUMBER_X]
FROM
[TABLE]
) AS [T1]
WHERE
([X_SEQUEL_ROW_NUMBER_X] > 10)

This sql is incorrect, and raise error "Sequel::DatabaseError - TinyTds::Error: Incorrect syntax near ','.".
Remove () which surrounding column names, then it works.