diff --git a/packages/nocodb/src/helpers/columnHelpers.ts b/packages/nocodb/src/helpers/columnHelpers.ts index 9c7f80e6ef..66192845d4 100644 --- a/packages/nocodb/src/helpers/columnHelpers.ts +++ b/packages/nocodb/src/helpers/columnHelpers.ts @@ -264,5 +264,10 @@ export async function populateRollupForLTAR({ } export const sanitizeColumnName = (name: string) => { - return name.replace(/\W+/g, '_').trim(); + const columnName = name.replace(/\W+/g, '_').trim(); + + // if column name only contains _ then return as 'field' + if (/^_+$/.test(columnName)) return 'field'; + + return columnName; }; diff --git a/packages/nocodb/src/services/columns.service.ts b/packages/nocodb/src/services/columns.service.ts index 5748e17ad9..d08417cb35 100644 --- a/packages/nocodb/src/services/columns.service.ts +++ b/packages/nocodb/src/services/columns.service.ts @@ -123,10 +123,7 @@ export class ColumnsService { param.column.column_name = sanitizeColumnName(param.column.column_name); } - if ( - param.column.column_name && - param.column.column_name.length > mxColumnLength - ) { + if (param.column.column_name) { // - 5 is a buffer for suffix let colName = param.column.column_name.slice(0, mxColumnLength - 5); let suffix = 1; @@ -1069,10 +1066,7 @@ export class ColumnsService { param.column.column_name = sanitizeColumnName(param.column.column_name); } - if ( - param.column.column_name && - param.column.column_name.length > mxColumnLength - ) { + if (param.column.column_name) { // - 5 is a buffer for suffix let colName = param.column.column_name.slice(0, mxColumnLength - 5); let suffix = 1;