dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

Offset and limit not work on mysql #687

Open JayceLin opened 8 years ago

dxg commented 8 years ago

The tests say it does work.

JayceLin commented 8 years ago

Maybe something mistake I make. When I used "model.find(condition).offset(0).limit(20)" or “model.find(condition,{offset:0,limit:20})”, they didn't work. Then I change to db.execQuery to run the native sql, and it works.

lvanbuiten commented 8 years ago

JayceLin shouldn't it be: model.find(condition).limit(20).offset(0)? Offset is an addition on the limit functionality. Mysql query should be looking like this: SELECT * FROM [table] LIMIT 10 OFFSET 5; and not: SELECT * FROM [table] OFFSET 5 LIMIT 10;

Hope it works