Browse Source

fix(nocodb): sanitize / unsanitize logic

pull/5293/head
Wing-Kam Wong 2 years ago
parent
commit
494cb210fa
  1. 9
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

9
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;
}

Loading…
Cancel
Save