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

Loading…
Cancel
Save