When the query is generated it's select COUNT(*) from "user" as "user" limit 10 offset 10, mySQL then decides that it doesn't like this and gives you no results.
Can you solve it?
This seems to be more a problem with wetland itself (or knex.js). One solution is to use SQL_CALC_FOUND_ROWS instead of Count when using mySQL. But I have no idea where to start.
How did you solve it now
I just take the options object and remove the offset attribute form it. This seems like a really hacky solution and I don't think it's PR worthy. Maybe the god maintainer of this project can assist me in writing a fix.
How to recreate this bug:
countInResponse:
option (For instanceX-Total-Count
)users
) in Sailsusers
table with 100 usersGET
call on the users resource (http://local.dev/users?limit=10
). 😃 Yay it works, I get a value in the headerGET
call on the users resource with an offset (http://local.dev/users?limit=10&offset=20
) ðŸ˜, The header value isnull
Why is this happening:
In the https://github.com/SpoonX/sails-hook-wetland/blob/master/lib/count.js file on line
13
options are added. If offset is set on one of those options you get the resultnull
.When the query is generated it's
select COUNT(*) from "user" as "user" limit 10 offset 10
, mySQL then decides that it doesn't like this and gives you no results.Can you solve it? This seems to be more a problem with wetland itself (or knex.js). One solution is to use
SQL_CALC_FOUND_ROWS
instead ofCount
when using mySQL. But I have no idea where to start.How did you solve it now I just take the options object and remove the offset attribute form it. This seems like a really hacky solution and I don't think it's PR worthy. Maybe the
godmaintainer of this project can assist me in writing a fix.