diff --git a/packages/server/src/api/controllers/row/ExternalRequest.ts b/packages/server/src/api/controllers/row/ExternalRequest.ts index dc62453f77..852f124ee5 100644 --- a/packages/server/src/api/controllers/row/ExternalRequest.ts +++ b/packages/server/src/api/controllers/row/ExternalRequest.ts @@ -282,9 +282,11 @@ module External { const linkTablePrimary = linkTable.primary[0] // one to many if (isOneSide(field)) { - newRow[field.foreignKey || linkTablePrimary] = breakRowIdField( - row[key][0] - )[0] + let id = row[key][0] + if (typeof row[key] === "string") { + id = decodeURIComponent(row[key]).match(/\[(.*?)\]/)?.[1] + } + newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(id)[0] } // many to many else if (field.through) { diff --git a/packages/server/src/api/controllers/row/index.ts b/packages/server/src/api/controllers/row/index.ts index d9797b4ec2..09af24a9b1 100644 --- a/packages/server/src/api/controllers/row/index.ts +++ b/packages/server/src/api/controllers/row/index.ts @@ -30,16 +30,24 @@ export async function patch(ctx: any): Promise { if (body && !body._id) { return save(ctx) } - const { row, table } = await quotas.addQuery( - () => pickApi(tableId).patch(ctx), - { - datasourceId: tableId, + try { + const { row, table } = await quotas.addQuery( + () => pickApi(tableId).patch(ctx), + { + datasourceId: tableId, + } + ) + if (!row) { + ctx.throw(404, "Row not found") } - ) - ctx.status = 200 - ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:update`, appId, row, table) - ctx.message = `${table.name} updated successfully.` - ctx.body = row + ctx.status = 200 + ctx.eventEmitter && + ctx.eventEmitter.emitRow(`row:update`, appId, row, table) + ctx.message = `${table.name} updated successfully.` + ctx.body = row + } catch (err) { + ctx.throw(400, err) + } } export const save = async (ctx: any) => { diff --git a/qa-core/src/config/internal-api/fixtures/types/unpublishAppResponse.ts b/qa-core/src/config/internal-api/fixtures/types/unpublishAppResponse.ts index 83b0c50352..277970fccb 100644 --- a/qa-core/src/config/internal-api/fixtures/types/unpublishAppResponse.ts +++ b/qa-core/src/config/internal-api/fixtures/types/unpublishAppResponse.ts @@ -1,7 +1,7 @@ export interface UnpublishAppResponse { - data: { - ok: boolean - }, - ok: boolean, - status: number + data: { + ok: boolean + } + ok: boolean + status: number }