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

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

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

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

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

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

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

Loading…
Cancel
Save