diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts index e5902ab23c..1836a1453d 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts @@ -324,7 +324,14 @@ class BaseModelSqlv2 { qb.count(sanitize(this.model.primaryKey?.column_name) || '*', { as: 'count', }).first(); - const res = (await this.dbDriver.raw(unsanitize(qb.toQuery()))) as any; + + let sql = sanitize(qb.toQuery()); + if (!this.isPg && !this.isMssql && !this.isSnowflake) { + sql = unsanitize(qb.toQuery()); + } + + const res = (await this.dbDriver.raw(sql)) as any; + return (this.isPg || this.isSnowflake ? res.rows[0] : res[0][0] ?? res[0]) .count; }