Browse Source

fix: incorrect row size in hm

pull/6360/head
DarkPhoenix2704 1 year ago
parent
commit
713bdde5ba
  1. 14
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 2
      packages/nocodb/src/services/data-alias-nested.service.ts
  3. 2
      packages/nocodb/src/services/data-table.service.ts
  4. 2
      packages/nocodb/src/services/datas.service.ts
  5. 11
      packages/nocodb/src/services/public-datas.service.ts

14
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -841,9 +841,10 @@ class BaseModelSqlv2 {
}
}
async hmListCount({ colId, id }) {
async hmListCount({ colId, id }, args) {
try {
// const { cn } = this.hasManyRelations.find(({ tn }) => tn === child) || {};
const { where } = this._getListArgs(args as any);
const relColumn = (await this.model.getColumns()).find(
(c) => c.id === colId,
);
@ -867,10 +868,13 @@ class BaseModelSqlv2 {
this.dbDriver(parentTn)
.select(parentCol.column_name)
.where(_wherePk(parentTable.primaryKeys, id)),
)
.first();
const { count } = await query;
return count;
);
const aliasColObjMap = await childTable.getAliasColObjMap();
const filterObj = extractFilterFromXwhere(where, aliasColObjMap);
await conditionV2(this, filterObj, query);
return (await query.first())?.count;
} catch (e) {
console.log(e);
throw e;

2
packages/nocodb/src/services/data-alias-nested.service.ts

@ -223,7 +223,7 @@ export class DataAliasNestedService {
const count = await baseModel.hmListCount({
colId: column.id,
id: param.rowId,
});
}, param.query);
return new PagedResponseImpl(data, {
count,

2
packages/nocodb/src/services/data-table.service.ts

@ -305,7 +305,7 @@ export class DataTableService {
count = (await baseModel.hmListCount({
colId: column.id,
id: param.rowId,
})) as number;
}, param.query)) as number;
} else {
data = await baseModel.btRead(
{

2
packages/nocodb/src/services/datas.service.ts

@ -653,7 +653,7 @@ export class DatasService {
const count = await baseModel.hmListCount({
colId: param.colId,
id: param.rowId,
});
}, param.query);
return new PagedResponseImpl(data, {
totalRows: count,

11
packages/nocodb/src/services/public-datas.service.ts

@ -546,10 +546,13 @@ export class PublicDatasService {
)
)?.[key];
const count = await baseModel.hmListCount({
colId: param.columnId,
id: param.rowId,
});
const count = await baseModel.hmListCount(
{
colId: param.columnId,
id: param.rowId,
},
param.query,
);
return new PagedResponseImpl(data, { ...param.query, count });
}

Loading…
Cancel
Save