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")
}
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(
response: DatasourcePlusQueryResponse
): number {
if (response && response.length === 1 && "total" in response[0]) {
const total = response[0].total
if (response && response.length === 1 && "__bb_total" in response[0]) {
const total = response[0].__bb_total
return typeof total === "number" ? total : parseInt(total)
} else {
throw new Error("Unable to count rows in query - no count response")