Browse Source

fix: bug with duplicating table (WIP)

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5848/head
Pranav C 1 year ago
parent
commit
f861144442
  1. 6
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.processor.ts
  2. 5
      packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts

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

@ -2,8 +2,8 @@ import { Readable } from 'stream';
import { Process, Processor } from '@nestjs/bull'; import { Process, Processor } from '@nestjs/bull';
import { Job } from 'bull'; import { Job } from 'bull';
import papaparse from 'papaparse'; import papaparse from 'papaparse';
import { UITypes } from 'nocodb-sdk';
import { Logger } from '@nestjs/common'; import { Logger } from '@nestjs/common';
import { isLinksOrLTAR } from '../../../../../../nocodb-sdk/src'
import { Base, Column, Model, Project } from '../../../../models'; import { Base, Column, Model, Project } from '../../../../models';
import { ProjectsService } from '../../../../services/projects.service'; import { ProjectsService } from '../../../../services/projects.service';
import { findWithIdentifier } from '../../../../helpers/exportImportHelpers'; import { findWithIdentifier } from '../../../../helpers/exportImportHelpers';
@ -137,7 +137,7 @@ export class DuplicateProcessor {
await sourceModel.getColumns(); await sourceModel.getColumns();
const relatedModelIds = sourceModel.columns const relatedModelIds = sourceModel.columns
.filter((col) => col.uidt === UITypes.LinkToAnotherRecord) .filter((col) => isLinksOrLTAR(col))
.map((col) => col.colOptions.fk_related_model_id) .map((col) => col.colOptions.fk_related_model_id)
.filter((id) => id); .filter((id) => id);
@ -186,7 +186,7 @@ export class DuplicateProcessor {
const bts = md.columns const bts = md.columns
.filter( .filter(
(c) => (c) =>
c.uidt === UITypes.LinkToAnotherRecord && isLinksOrLTAR(c) &&
c.colOptions.type === 'bt' && c.colOptions.type === 'bt' &&
c.colOptions.fk_related_model_id === modelId, c.colOptions.fk_related_model_id === modelId,
) )

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

@ -1,6 +1,7 @@
import { UITypes, ViewTypes } from 'nocodb-sdk'; import { UITypes, ViewTypes } from 'nocodb-sdk';
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import papaparse from 'papaparse'; import papaparse from 'papaparse';
import { isLinksOrLTAR } from '../../../../../../nocodb-sdk/src'
import { import {
findWithIdentifier, findWithIdentifier,
generateUniqueName, generateUniqueName,
@ -125,7 +126,7 @@ export class ImportService {
const reducedColumnSet = modelData.columns.filter( const reducedColumnSet = modelData.columns.filter(
(a) => (a) =>
a.uidt !== UITypes.LinkToAnotherRecord && !isLinksOrLTAR(a) &&
a.uidt !== UITypes.Lookup && a.uidt !== UITypes.Lookup &&
a.uidt !== UITypes.Rollup && a.uidt !== UITypes.Rollup &&
a.uidt !== UITypes.Formula && a.uidt !== UITypes.Formula &&
@ -166,7 +167,7 @@ export class ImportService {
const table = tableReferences.get(modelData.id); const table = tableReferences.get(modelData.id);
const linkedColumnSet = modelData.columns.filter( const linkedColumnSet = modelData.columns.filter(
(a) => a.uidt === UITypes.LinkToAnotherRecord, (a) => isLinksOrLTAR(a)
); );
for (const col of linkedColumnSet) { for (const col of linkedColumnSet) {

Loading…
Cancel
Save