Browse Source

fix: use uidt from request on table creation

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1938/head
Pranav C 3 years ago
parent
commit
737c2ded65
  1. 21
      packages/nocodb/src/lib/noco/meta/api/tableApis.ts

21
packages/nocodb/src/lib/noco/meta/api/tableApis.ts

@ -167,15 +167,18 @@ export async function tableCreate(req: Request<any, any, TableReqType>, res) {
res.json( res.json(
await Model.insert(project.id, base.id, { await Model.insert(project.id, base.id, {
...req.body, ...req.body,
columns: columns.map((c, i) => ({ columns: columns.map((c, i) => {
uidt: c.uidt || getColumnUiType(base, c), const colMetaFromReq = req.body?.columns?.find(
...c, c1 => c.cn === c1.column_name
title: );
req.body?.columns?.find(c1 => c.cn === c1.column_name)?.title || return {
getColumnNameAlias(c.cn, base), uidt: colMetaFromReq?.uidt || c.uidt || getColumnUiType(base, c),
column_name: c.cn, ...c,
order: i + 1 title: colMetaFromReq?.title || getColumnNameAlias(c.cn, base),
})), column_name: c.cn,
order: i + 1
};
}),
order: +(tables?.pop()?.order ?? 0) + 1 order: +(tables?.pop()?.order ?? 0) + 1
}) })
); );

Loading…
Cancel
Save