Closes #1092.
The two paginate APIs take the same two numbers in opposite orders:
db.selectFrom(t).paginate(perPage, page)
Model.query().paginate(page, perPage)Both parameters are number, so transposing them is not a type error — you just receive a different page, with nothing to tell you. forPage(page, perPage) sits ~60 lines from the builder's paginate(perPage, page) and takes the opposite order again, which is presumably where this came from.
Why additive
Realigning either side is a one-line change and a silent break for every existing caller of whichever side moves — same call, same types, different rows. There is no deprecation path for that, because there is no way to detect the old intent at runtime.
So instead:
- both APIs also accept
{ page, perPage }, where naming the arguments makes the order irrelevant - both keep their positional forms, behaviour unchanged
- the ORM result gains a
metaobject mirroring the builder's, keeping every flat field it already returned
// means the same thing on both, and cannot be got wrong
await db.selectFrom('t').paginate({ perPage: 5, page: 2 })
await Model.query().paginate({ perPage: 5, page: 2 })
// ORM result: flat fields untouched, meta added
{ data, total, page, perPage, lastPage, hasMorePages, isEmpty, from, to,
meta: { perPage, page, total, lastPage } }A helper that reads result.meta.total now works against either API — which was the other half of the issue, and the half that at least failed loudly.
The positional divergence itself is left for a deliberate major. This adds the safe path; it does not pretend the trap is gone.
Verification
8 new tests: the options form matches the positional result on the builder, the ORM's positional order is untouched, page defaults to 1, the existing perPage/page validation still fires through the options form, the ORM's flat fields are unchanged, and orm.meta deep-equals builder.meta for the same page — which is the property the addition exists to provide.
Full suite 2124 pass / 0 fail, typecheck clean, pickier 0 errors.
🤖 Generated with Claude Code