diff --git a/packages/nc-gui/components/dlg/ColumnDuplicate.vue b/packages/nc-gui/components/dlg/ColumnDuplicate.vue index 82dd82612c..2c87a60ca0 100644 --- a/packages/nc-gui/components/dlg/ColumnDuplicate.vue +++ b/packages/nc-gui/components/dlg/ColumnDuplicate.vue @@ -17,10 +17,6 @@ const dialogShow = useVModel(props, 'modelValue', emit) const { $e, $poller } = useNuxtApp() -const basesStore = useBases() - -const { createProject: _createProject } = basesStore - const { activeTable: _activeTable } = storeToRefs(useTablesStore()) const reloadDataHook = inject(ReloadViewDataHookInj) @@ -101,7 +97,9 @@ onKeyStroke('Enter', () => { } }) -const isEaster = ref(false) +defineExpose({ + duplicate: _duplicate, +}) diff --git a/packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.processor.ts b/packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.processor.ts index 34c0da3e59..090f199688 100644 --- a/packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.processor.ts +++ b/packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.processor.ts @@ -3,7 +3,7 @@ import { Process, Processor } from '@nestjs/bull'; import { Job } from 'bull'; import papaparse from 'papaparse'; import debug from 'debug'; -import { isLinksOrLTAR } from 'nocodb-sdk'; +import { isLinksOrLTAR, isVirtualCol } from 'nocodb-sdk'; import { Base, Column, Model, Source } from '~/models'; import { BasesService } from '~/services/bases.service'; import { @@ -373,14 +373,16 @@ export class DuplicateProcessor { }); // update cdf - await this.columnsService.columnUpdate({ - columnId: findWithIdentifier(idMap, sourceColumn.id), - column: { - ...destColumn, - cdf: oldCdf, - }, - user: req.user, - }); + if (!isVirtualCol(destColumn)) { + await this.columnsService.columnUpdate({ + columnId: findWithIdentifier(idMap, sourceColumn.id), + column: { + ...destColumn, + cdf: oldCdf, + }, + user: req.user, + }); + } this.debugLog(`job completed for ${job.id} (${JobTypes.DuplicateModel})`); diff --git a/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts b/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts index c34ae99cf0..885d279989 100644 --- a/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts +++ b/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts @@ -129,6 +129,17 @@ export class ExportService { } break; case 'formula': + // rewrite formula_raw with aliases + column.colOptions['formula_raw'] = column.colOptions[k].replace( + /\{\{.*?\}\}/gm, + (match) => { + const col = model.columns.find( + (c) => c.id === match.slice(2, -2), + ); + return `{${col?.title}}`; + }, + ); + column.colOptions[k] = column.colOptions[k].replace( /(?<=\{\{).*?(?=\}\})/gm, (match) => idMap.get(match),