Browse Source

fix: qrcode and barcode duplicate

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/6953/head
mertmit 1 year ago
parent
commit
0326ad3f7c
  1. 4
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 2
      packages/nocodb/src/helpers/columnHelpers.ts
  3. 5
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.processor.ts
  4. 5
      packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts

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

@ -2148,7 +2148,7 @@ class BaseModelSqlv2 {
aliasToColumnBuilder, aliasToColumnBuilder,
); );
qb.select({ qb.select({
[column.column_name]: selectQb.builder, [column.title]: selectQb.builder,
}); });
} catch { } catch {
continue; continue;
@ -2156,7 +2156,7 @@ class BaseModelSqlv2 {
break; break;
default: { default: {
qb.select({ qb.select({
[column.column_name]: barcodeValueColumn.column_name, [column.title]: barcodeValueColumn.column_name,
}); });
break; break;
} }

2
packages/nocodb/src/helpers/columnHelpers.ts

@ -267,7 +267,7 @@ export async function populateRollupForLTAR({
} }
export const sanitizeColumnName = (name: string) => { export const sanitizeColumnName = (name: string) => {
const columnName = name.replace(/\W+/g, '_').trim(); const columnName = name.replace(/\W/g, '_');
// if column name only contains _ then return as 'field' // if column name only contains _ then return as 'field'
if (/^_+$/.test(columnName)) return 'field'; if (/^_+$/.test(columnName)) return 'field';

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

@ -290,10 +290,6 @@ export class DuplicateProcessor {
throw new Error(`Export failed for model '${sourceModel.id}'`); throw new Error(`Export failed for model '${sourceModel.id}'`);
} }
const serializedPrimaryKey = exportedModel.model.columns.find((c) =>
c.id.includes(sourceModel.primaryKey.id),
);
exportedModel.model.columns = exportedModel.model.columns.filter((c) => exportedModel.model.columns = exportedModel.model.columns.filter((c) =>
c.id.includes(columnId), c.id.includes(columnId),
); );
@ -329,7 +325,6 @@ export class DuplicateProcessor {
if (!excludeData) { if (!excludeData) {
const fields: Record<string, string[]> = {}; const fields: Record<string, string[]> = {};
idMap.set(serializedPrimaryKey.id, sourceModel.primaryKey.id);
fields[sourceModel.id] = [sourceModel.primaryKey.id]; fields[sourceModel.id] = [sourceModel.primaryKey.id];
fields[sourceModel.id].push(columnId); fields[sourceModel.id].push(columnId);

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

@ -94,6 +94,10 @@ export class ImportService {
param.data = Array.isArray(param.data) ? param.data : param.data.models; param.data = Array.isArray(param.data) ? param.data : param.data.models;
// allow existing model to be linked
if (param.existingModel)
param.externalModels = [param.existingModel, ...param.externalModels];
// allow existing models to be linked // allow existing models to be linked
if (param.externalModels) { if (param.externalModels) {
for (const model of param.externalModels) { for (const model of param.externalModels) {
@ -910,6 +914,7 @@ export class ImportService {
} }
} }
} else if (col.uidt === UITypes.Barcode) { } else if (col.uidt === UITypes.Barcode) {
flatCol.validate = null;
const freshModelData = await this.columnsService.columnAdd({ const freshModelData = await this.columnsService.columnAdd({
tableId: getIdOrExternalId(getParentIdentifier(col.id)), tableId: getIdOrExternalId(getParentIdentifier(col.id)),
column: withoutId({ column: withoutId({

Loading…
Cancel
Save