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

Loading…
Cancel
Save