Closed andrew-connell closed 1 year ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Well it definitely still exists as an issue
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Package version
18.3.0
Node.js and npm version
Node 18.13.0, npm 9.3.0
Sample Code (to reproduce the issue)
await Record.query().distinct('vehicle_id').paginate(1)
It produces the following queries.
The first one should be
SELECT COUNT(DISTINCT("vehicle_id")) AS "total" FROM "records"
It's an easy fix but I'm no expert on the underlying system so my code probably isn't amazing.
But in the paginate function I do
const distinct = this.knexQuery['_statements'].find((statement) => statement.distinct)?.value
and then if it exists, take that into consideration with the query