olavim / objection-cursor

Cursor based pagination plugin for Objection.js
MIT License
30 stars 8 forks source link

order by is gone when mix where and whereRaw, select and selectRaw together #5

Closed michellechsy closed 5 years ago

michellechsy commented 5 years ago

Our query is complex, which includes joining several tables, and conditions may cover all the tables (depends on what user provides), which looks like: Model.query().select(<table fields>).select(Model.knex().raw(CASE WHEN xxxxxxxx)).where(xxx).whereRaw(xxx).orderBy(xxxx)

  1. When querying without any conditions, i.e. no 'where' clause above, pagination works well
  2. When querying with conditions, e.g. a whereRaw in above query, pagination is incorrect, and according to the printout, the 'order by' was gone, remaining in the result 'pageInfo' is incorrect either (1-10, 7-16, and then even i click go 'previous', it still goes to 26-36)
olavim commented 5 years ago

I couldn't reproduce this by just using select, select(<raw query>), where, and whereRaw with my test data. Could you give me the exact query you use, or better yet, a repository with failing code.

olavim commented 5 years ago

Please try version 1.0.0-alpha.1. The release includes a couple of fixes which might solve your issues.

olavim commented 5 years ago

@michellechsy are you still having issues?