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 }) );