Browse Source

fix: bt link api correction

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5901/head
Pranav C 1 year ago
parent
commit
d5e41e7621
  1. 28
      packages/nocodb/src/db/BaseModelSqlv2.ts

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

@ -3677,17 +3677,10 @@ class BaseModelSqlv2 {
.where(_wherePk(parentTable.primaryKeys, childIds[0])) .where(_wherePk(parentTable.primaryKeys, childIds[0]))
.first(); .first();
const childRows = await childRowsQb; const childRow = await childRowsQb;
if (childRows.length !== childIds.length) { if (!childRow) {
const missingIds = childIds.filter( NcError.notFound(`Child record with id ${childIds[0]} not found`);
(id) =>
!childRows.find((r) => r[parentColumn.column_name] === id),
);
NcError.notFound(
`Child record with id ${missingIds.join(', ')} not found`,
);
} }
} }
@ -3841,20 +3834,13 @@ class BaseModelSqlv2 {
{ {
const childRowsQb = this.dbDriver(parentTn) const childRowsQb = this.dbDriver(parentTn)
.select(parentTable.primaryKey.column_name) .select(parentTable.primaryKey.column_name)
.whereIn(parentTable.primaryKey.column_name, childIds) .where(_wherePk(parentTable.primaryKeys, childIds[0]))
.first(); .first();
const childRows = await childRowsQb; const childRow = await childRowsQb;
if (childRows.length !== childIds.length) {
const missingIds = childIds.filter(
(id) =>
!childRows.find((r) => r[parentColumn.column_name] === id),
);
NcError.notFound( if (!childRow) {
`Child record with id ${missingIds.join(', ')} not found`, NcError.notFound(`Child record with id ${childIds[0]} not found`);
);
} }
} }

Loading…
Cancel
Save