{"action":"created","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/4404","repository_url":"https://api.github.com/repos/sequelize/sequelize","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/4404/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/4404/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/4404/events","html_url":"https://github.com/sequelize/sequelize/issues/4404","id":103806457,"number":4404,"title":"MSSQL query generator uses OFFSET FETCH clause only supported in SQL Server 2012 and up","user":{"login":"treythomas123","id":2589390,"avatar_url":"https://avatars.githubusercontent.com/u/2589390?v=3","gravatar_id":"","url":"https://api.github.com/users/treythomas123","html_url":"https://github.com/treythomas123","followers_url":"https://api.github.com/users/treythomas123/followers","following_url":"https://api.github.com/users/treythomas123/following{/other_user}","gists_url":"https://api.github.com/users/treythomas123/gists{/gist_id}","starred_url":"https://api.github.com/users/treythomas123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treythomas123/subscriptions","organizations_url":"https://api.github.com/users/treythomas123/orgs","repos_url":"https://api.github.com/users/treythomas123/repos","events_url":"https://api.github.com/users/treythomas123/events{/privacy}","received_events_url":"https://api.github.com/users/treythomas123/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sequelize/sequelize/labels/bug","name":"bug","color":"d7e102"},{"url":"https://api.github.com/repos/sequelize/sequelize/labels/mssql","name":"mssql","color":"bfdadc"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2015-08-28T22:34:39Z","updated_at":"2016-10-20T18:38:16Z","closed_at":"2016-05-13T06:41:22Z","body":"The query generator uses an OFFSET FETCH clause to apply the offset and limit parameters, which works fine in SQL Server 2012 and newer, but is unsupported in older versions of SQL Server.\r\n\r\n[Link to relevant code](https://github.com/sequelize/sequelize/blob/88217aea7ec6380739697de89dba2a830ada19ea/lib/dialects/mssql/query-generator.js#L586-L599)\r\n\r\nI found this when I tried to use `findById` against an SQL Server 2008 R2 database. The server came back with this error message:\r\n\r\n    Invalid usage of the option NEXT in the FETCH statement.\r\n\r\nLooking at the code, it looks like this will also happen when using `findOne`, or when the `offset` or `limit` options are used in a `findAll`, `findAndCount`, etc.\r\n\r\nSo the `offset` and `limit` functionality should either be changed to use a syntax supported by all SQL Server versions, or there should be logic to fall back to an old method when a version before 2012 is detected. Or the docs could be updated to specify that only versions newer than 2012 are supported."},"comment":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/255191337","html_url":"https://github.com/sequelize/sequelize/issues/4404#issuecomment-255191337","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/4404","id":255191337,"user":{"login":"Meloncon","id":583455,"avatar_url":"https://avatars.githubusercontent.com/u/583455?v=3","gravatar_id":"","url":"https://api.github.com/users/Meloncon","html_url":"https://github.com/Meloncon","followers_url":"https://api.github.com/users/Meloncon/followers","following_url":"https://api.github.com/users/Meloncon/following{/other_user}","gists_url":"https://api.github.com/users/Meloncon/gists{/gist_id}","starred_url":"https://api.github.com/users/Meloncon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Meloncon/subscriptions","organizations_url":"https://api.github.com/users/Meloncon/orgs","repos_url":"https://api.github.com/users/Meloncon/repos","events_url":"https://api.github.com/users/Meloncon/events{/privacy}","received_events_url":"https://api.github.com/users/Meloncon/received_events","type":"User","site_admin":false},"created_at":"2016-10-20T18:38:16Z","updated_at":"2016-10-20T18:38:16Z","body":"I am also having the same problem. I'm connecting to a Microsoft SQL Server 2012 - 11.0.5613.0 server using [Feathers](http://feathersjs.com/), Sequelize, and Tedious. Here's the exact error text I'm receiving: \r\n\r\n`Error: Invalid usage of the option NEXT in the FETCH statement.`\r\n\r\nNot sure where to go from here."}}
{"actor":{"display_login":"Meloncon"}}