From cda0408ce19bb8697f2a79a7d3bc89e70f3ef795 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 16 Oct 2024 10:30:46 +0000 Subject: [PATCH] refactor: instead of column_name make title mandatory for column create --- packages/nocodb/src/schema/swagger.json | 2 +- packages/nocodb/src/services/columns.service.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json index d29b9feede..b12bcd423e 100644 --- a/packages/nocodb/src/schema/swagger.json +++ b/packages/nocodb/src/schema/swagger.json @@ -23698,7 +23698,7 @@ "title": "Normal Column Request Model", "type": "object", "required": [ - "column_name" + "title" ], "x-stoplight": { "id": "fn3gqmojvswv2" diff --git a/packages/nocodb/src/services/columns.service.ts b/packages/nocodb/src/services/columns.service.ts index 923f4eee17..e79f74df63 100644 --- a/packages/nocodb/src/services/columns.service.ts +++ b/packages/nocodb/src/services/columns.service.ts @@ -16,6 +16,7 @@ import { } from 'nocodb-sdk'; import { pluralize, singularize } from 'inflection'; import hash from 'object-hash'; +import { parseMetaProp } from 'src/utils/modelUtils'; import type { ColumnReqType, LinkToAnotherColumnReqType, @@ -65,7 +66,6 @@ import Noco from '~/Noco'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import { MetaTable } from '~/utils/globals'; import { MetaService } from '~/meta/meta.service'; -import { parseMetaProp } from 'src/utils/modelUtils'; // todo: move export enum Altered { @@ -1674,6 +1674,11 @@ export class ColumnsService { param.column.title = param.column.title.trim(); } + // if column_name missing then generate it from title + if (!param.column.column_name) { + param.column.column_name = param.column.title; + } + if (param.column.column_name) { // - 5 is a buffer for suffix let colName = param.column.column_name.slice(0, mxColumnLength - 5);