From 5082c873199a89ed6bebecd0587157c7b79537b9 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 17 Feb 2023 18:11:02 +0800 Subject: [PATCH] fix(nocodb): cover title case for validation --- packages/nocodb/src/lib/meta/api/columnApis.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/columnApis.ts b/packages/nocodb/src/lib/meta/api/columnApis.ts index 30751c9c48..ab36b0103c 100644 --- a/packages/nocodb/src/lib/meta/api/columnApis.ts +++ b/packages/nocodb/src/lib/meta/api/columnApis.ts @@ -69,16 +69,20 @@ export async function columnAdd( const project = await base.getProject(); - const dbDriver = NcConnectionMgrv2.get(base); + if (req.body.title || req.body.column_name) { + const dbDriver = NcConnectionMgrv2.get(base); - const sqlClientType = dbDriver.clientType(); + const sqlClientType = dbDriver.clientType(); - const mxColumnLength = Column.getMaxColumnNameLength(sqlClientType); + const mxColumnLength = Column.getMaxColumnNameLength(sqlClientType); - if (req.body.column_name.length > mxColumnLength) { - NcError.badRequest( - `Column name ${req.body.column_name} exceeds ${mxColumnLength} characters` - ); + if ((req.body.title || req.body.column_name).length > mxColumnLength) { + NcError.badRequest( + `Column name ${ + req.body.title || req.body.column_name + } exceeds ${mxColumnLength} characters` + ); + } } if (