From d4639c379baddf7fa816ebac7403992e88f982f1 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 15 Nov 2024 10:52:01 +0000 Subject: [PATCH] fix: while populating insert object check row for nested object --- packages/nc-gui/components/general/Gift.vue | 2 +- packages/nc-gui/utils/dataUtils.ts | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/nc-gui/components/general/Gift.vue b/packages/nc-gui/components/general/Gift.vue index 516afc6f9b..87ba937606 100644 --- a/packages/nc-gui/components/general/Gift.vue +++ b/packages/nc-gui/components/general/Gift.vue @@ -59,7 +59,7 @@ const closeAndShowAgain = () => {

Gifts Unlocked!

-
We are giving away $100 worth of amazon coupons to our pro open source users!
+
We are giving away $50 worth of amazon coupons to our pro open source users!
diff --git a/packages/nc-gui/utils/dataUtils.ts b/packages/nc-gui/utils/dataUtils.ts index 5628f492d0..2fa8fe2cce 100644 --- a/packages/nc-gui/utils/dataUtils.ts +++ b/packages/nc-gui/utils/dataUtils.ts @@ -81,7 +81,6 @@ export async function populateInsertObject({ throwError?: boolean undo?: boolean }) { - debugger const missingRequiredColumns = new Set() const insertObj = await meta.columns?.reduce(async (_o: Promise, col) => { const o = await _o @@ -92,14 +91,14 @@ export async function populateInsertObject({ col.uidt === UITypes.LinkToAnotherRecord && (col.colOptions).type === RelationTypes.BELONGS_TO ) { - if (ltarState[col.title!]) { + if (ltarState[col.title!] || row[col.title!]) { + const ltarVal = ltarState[col.title!] || row[col.title!] const colOpt = col.colOptions const childCol = meta.columns!.find((c) => colOpt.fk_child_column_id === c.id) const relatedTableMeta = (await getMeta(colOpt.fk_related_model_id!)) as TableType if (relatedTableMeta && childCol) { - o[childCol.title!] = - ltarState[col.title!][relatedTableMeta!.columns!.find((c) => c.id === colOpt.fk_parent_column_id)!.title!] - missingRequiredColumns.delete(childCol.title) + o[childCol.title!] = ltarVal[relatedTableMeta!.columns!.find((c) => c.id === colOpt.fk_parent_column_id)!.title!] + if (o[childCol.title!] !== null && o[childCol.title!] !== undefined) missingRequiredColumns.delete(childCol.title) } } }