Browse Source

feat: attachment handling for duplicate model

nc-feat/attachment-clean-up
mertmit 4 months ago
parent
commit
f04949baa6
  1. 10
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 6
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.processor.ts
  3. 8
      packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts

10
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -5288,6 +5288,14 @@ class BaseModelSqlv2 {
aiPkCol = this.model.primaryKeys.find((pk) => pk.ai);
agPkCol = this.model.primaryKeys.find((pk) => pk.meta?.ag);
} else {
await this.model.getColumns(this.context);
await Promise.all(
insertDatas.map(
async (d) => await this.prepareNocoData(d, true, cookie),
),
);
}
if ('beforeBulkInsert' in this) {
@ -5344,11 +5352,9 @@ class BaseModelSqlv2 {
} else {
const returningObj: Record<string, string> = {};
if (!raw) {
for (const col of this.model.primaryKeys) {
returningObj[col.title] = col.column_name;
}
}
responses =
!raw && (this.isPg || this.isMssql)

6
packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.processor.ts

@ -113,6 +113,7 @@ export class DuplicateProcessor {
destProject: dupProject,
destBase: dupBase,
hrTime,
req,
});
}
@ -241,6 +242,7 @@ export class DuplicateProcessor {
hrTime,
modelFieldIds: fields,
externalModels: relatedModels,
req,
});
elapsedTime(hrTime, 'import model data', 'duplicateModel');
@ -381,6 +383,7 @@ export class DuplicateProcessor {
sourceModel,
...relatedModels.filter((m) => m.id !== sourceModel.id),
],
req,
});
elapsedTime(hrTime, 'import model data', 'duplicateColumn');
@ -420,6 +423,7 @@ export class DuplicateProcessor {
hrTime: { hrTime: [number, number] };
modelFieldIds?: Record<string, string[]>;
externalModels?: Model[];
req: any;
},
) {
const {
@ -431,6 +435,7 @@ export class DuplicateProcessor {
hrTime,
modelFieldIds,
externalModels,
req,
} = param;
let handledLinks = [];
@ -474,6 +479,7 @@ export class DuplicateProcessor {
destProject,
destBase,
destModel: model,
req,
});
handledLinks = await this.importService.importLinkFromCsvStream(

8
packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts

@ -1688,6 +1688,7 @@ export class ImportService {
destProject,
destBase,
destModel: model,
req,
});
elapsedTime(
@ -1735,9 +1736,10 @@ export class ImportService {
destProject: Base;
destBase: Source;
destModel: Model;
req: any;
},
): Promise<void> {
const { idMap, dataStream, destBase, destProject, destModel } = param;
const { idMap, dataStream, destBase, destProject, destModel, req } = param;
const headers: string[] = [];
let chunk = [];
@ -1804,7 +1806,7 @@ export class ImportService {
baseName: destProject.id,
tableName: destModel.id,
body: chunk,
cookie: null,
cookie: req,
chunkSize: chunk.length + 1,
foreign_key_checks: !!destBase.isMeta(),
raw: true,
@ -1825,7 +1827,7 @@ export class ImportService {
baseName: destProject.id,
tableName: destModel.id,
body: chunk,
cookie: null,
cookie: req,
chunkSize: chunk.length + 1,
foreign_key_checks: !!destBase.isMeta(),
raw: true,

Loading…
Cancel
Save