Rename total field when doing row counts.
This commit is contained in:
parent
08f1c4dadc
commit
ddd229062c
|
@ -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`
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue