-
Notifications
You must be signed in to change notification settings - Fork 161
Closed
Labels
Description
I have submitted #169 to start addressing MSSQL server support, but then I discovered that a where clause is being used to window the query instead of offset.
The COUNT(1) OVER() statement will only return the count constrained by the where clause, so pageInfo.hasPrevious will never return true.
If the OFFSET was used instead, the count query would return the entire count, so hasPrevious would work as designed.
The only way that I can see this working is with a query like this:
SELECT [id]
, COUNT(1) OVER () AS [full_count]
FROM [Users] AS [User]
--Include where clause here if specified by user
ORDER BY [User].[id]
ASC OFFSET (
SELECT ISNULL(
(SELECT ROW_NUMBER() OVER(ORDER BY Id) FROM dbo.Users WHERE id = @LastId), --Include where clause here if specified by user
(SELECT COUNT(*) FROM dbo.Users) --Include where clause here if specified by user
)
) ROWS
FETCH NEXT 1 ROWS ONLY