Rename total field when doing row counts.

This commit is contained in:
Sam Rose 2024-10-02 09:39:54 +01:00
parent 08f1c4dadc
commit ddd229062c
No known key found for this signature in database
2 changed files with 3 additions and 3 deletions

View File

@ -842,7 +842,7 @@ class InternalBuilder {
throw new Error("SQL counting requires primary key to be supplied") throw new Error("SQL counting requires primary key to be supplied")
} }
return query.countDistinct( return query.countDistinct(
`${this.getTableName()}.${this.table.primary[0]} as total` `${this.getTableName()}.${this.table.primary[0]} as __bb_total`
) )
} }

View File

@ -57,8 +57,8 @@ export function getSQLClient(datasource: Datasource): SqlClient {
export function processRowCountResponse( export function processRowCountResponse(
response: DatasourcePlusQueryResponse response: DatasourcePlusQueryResponse
): number { ): number {
if (response && response.length === 1 && "total" in response[0]) { if (response && response.length === 1 && "__bb_total" in response[0]) {
const total = response[0].total const total = response[0].__bb_total
return typeof total === "number" ? total : parseInt(total) return typeof total === "number" ? total : parseInt(total)
} else { } else {
throw new Error("Unable to count rows in query - no count response") throw new Error("Unable to count rows in query - no count response")