From 737c2ded65f401a6d617965f34c854b550dcf39f Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 30 Apr 2022 14:30:54 +0530 Subject: [PATCH] fix: use uidt from request on table creation Signed-off-by: Pranav C --- .../nocodb/src/lib/noco/meta/api/tableApis.ts | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/nocodb/src/lib/noco/meta/api/tableApis.ts b/packages/nocodb/src/lib/noco/meta/api/tableApis.ts index 4b0926e2c0..9f8a6a5a04 100644 --- a/packages/nocodb/src/lib/noco/meta/api/tableApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/tableApis.ts @@ -167,15 +167,18 @@ export async function tableCreate(req: Request, res) { res.json( await Model.insert(project.id, base.id, { ...req.body, - columns: columns.map((c, i) => ({ - uidt: c.uidt || getColumnUiType(base, c), - ...c, - title: - req.body?.columns?.find(c1 => c.cn === c1.column_name)?.title || - getColumnNameAlias(c.cn, base), - column_name: c.cn, - order: i + 1 - })), + columns: columns.map((c, i) => { + const colMetaFromReq = req.body?.columns?.find( + c1 => c.cn === c1.column_name + ); + return { + uidt: colMetaFromReq?.uidt || c.uidt || getColumnUiType(base, c), + ...c, + title: colMetaFromReq?.title || getColumnNameAlias(c.cn, base), + column_name: c.cn, + order: i + 1 + }; + }), order: +(tables?.pop()?.order ?? 0) + 1 }) );