Browse Source

fix/Fixed pagination info of nestedChildrenExcludedList api where totalRows was set wrong due to bugged sql query

pull/3235/head
Muhammed Mustafa 2 years ago
parent
commit
56b72f29e1
  1. 21
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

21
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -251,7 +251,7 @@ class BaseModelSqlv2 {
if (!ignoreFilterSort) applyPaginate(qb, rest); if (!ignoreFilterSort) applyPaginate(qb, rest);
const proto = await this.getProto(); const proto = await this.getProto();
let data = await this.extractRawQueryAndExec(qb); const data = await this.extractRawQueryAndExec(qb);
return data?.map((d) => { return data?.map((d) => {
d.__proto__ = proto; d.__proto__ = proto;
@ -362,7 +362,7 @@ class BaseModelSqlv2 {
qb.groupBy(args.column_name); qb.groupBy(args.column_name);
if (sorts) await sortV2(sorts, qb, this.dbDriver); if (sorts) await sortV2(sorts, qb, this.dbDriver);
applyPaginate(qb, rest); applyPaginate(qb, rest);
let data = await qb; const data = await qb;
return data; return data;
} }
@ -571,7 +571,10 @@ class BaseModelSqlv2 {
} }
} }
public async multipleMmList({ colId, parentIds }, args: { limit?; offset? } = {}) { public async multipleMmList(
{ colId, parentIds },
args: { limit?; offset? } = {}
) {
const { where, ...rest } = this._getListArgs(args as any); const { where, ...rest } = 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
@ -879,7 +882,7 @@ class BaseModelSqlv2 {
applyPaginate(qb, rest); applyPaginate(qb, rest);
const proto = await childModel.getProto(); const proto = await childModel.getProto();
let data = await qb; const data = await qb;
return data.map((c) => { return data.map((c) => {
c.__proto__ = proto; c.__proto__ = proto;
@ -979,7 +982,7 @@ class BaseModelSqlv2 {
applyPaginate(qb, rest); applyPaginate(qb, rest);
const proto = await childModel.getProto(); const proto = await childModel.getProto();
let data = await this.extractRawQueryAndExec(qb); const data = await this.extractRawQueryAndExec(qb);
return data.map((c) => { return data.map((c) => {
c.__proto__ = proto; c.__proto__ = proto;
@ -1018,7 +1021,8 @@ class BaseModelSqlv2 {
.select(cn) .select(cn)
// .where(childTable.primaryKey.cn, cid) // .where(childTable.primaryKey.cn, cid)
.where(_wherePk(childTable.primaryKeys, cid)) .where(_wherePk(childTable.primaryKeys, cid))
).orWhereNull(rcn); .whereNotNull(cn)
);
}) })
.count(`*`, { as: 'count' }); .count(`*`, { as: 'count' });
@ -1079,7 +1083,7 @@ class BaseModelSqlv2 {
applyPaginate(qb, rest); applyPaginate(qb, rest);
const proto = await parentModel.getProto(); const proto = await parentModel.getProto();
let data = await this.extractRawQueryAndExec(qb); const data = await this.extractRawQueryAndExec(qb);
return data.map((c) => { return data.map((c) => {
c.__proto__ = proto; c.__proto__ = proto;
@ -1554,8 +1558,7 @@ class BaseModelSqlv2 {
{ {
const childCol = await colOptions.getChildColumn(); const childCol = await colOptions.getChildColumn();
const parentCol = await colOptions.getParentColumn(); const parentCol = await colOptions.getParentColumn();
insertObj[childCol.column_name] = insertObj[childCol.column_name] = nestedData?.[parentCol.title];
nestedData?.[parentCol.title];
} }
break; break;
case RelationTypes.HAS_MANY: case RelationTypes.HAS_MANY:

Loading…
Cancel
Save