diff --git a/packages/nocodb/src/meta/meta.service.ts b/packages/nocodb/src/meta/meta.service.ts index 03c7ce18e4..5074883b7d 100644 --- a/packages/nocodb/src/meta/meta.service.ts +++ b/packages/nocodb/src/meta/meta.service.ts @@ -125,6 +125,10 @@ export class MetaService { data: any | any[], ignoreIdGeneration?: boolean, ): Promise { + if (Array.isArray(data) ? !data.length : !data) { + return []; + } + const insertObj = []; const at = this.now(); diff --git a/packages/nocodb/src/models/View.ts b/packages/nocodb/src/models/View.ts index 1d5da22539..443929a098 100644 --- a/packages/nocodb/src/models/View.ts +++ b/packages/nocodb/src/models/View.ts @@ -1639,6 +1639,8 @@ export default class View implements ViewType { } } + if (isSystemColumn(column)) show = false; + insertObjs.push({ fk_column_id: column.id, order: order++, @@ -1683,6 +1685,14 @@ export default class View implements ViewType { insertObjs, ); break; + case ViewTypes.FORM: + await ncMeta.bulkMetaInsert( + null, + null, + MetaTable.FORM_VIEW_COLUMNS, + insertObjs, + ); + break; } } @@ -1853,7 +1863,10 @@ export default class View implements ViewType { ); // populate view columns - await View.bulkColumnInsertToViews({ viewColumns, copyFromView }, insertedView); + await View.bulkColumnInsertToViews( + { viewColumns, copyFromView }, + insertedView, + ); } else { // populate view columns await View.bulkColumnInsertToViews( @@ -1862,6 +1875,11 @@ export default class View implements ViewType { ); } + await Model.getNonDefaultViewsCountAndReset( + { modelId: view.fk_model_id }, + ncMeta, + ); + return insertedView; } }