Browse Source

refactor: on at import create instead of LTAR create Links

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5848/head
Pranav C 1 year ago
parent
commit
cfc4d46251
  1. 18
      packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts

18
packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts

@ -9,6 +9,7 @@ import utc from 'dayjs/plugin/utc';
import tinycolor from 'tinycolor2';
import { Process, Processor } from '@nestjs/bull';
import { Job } from 'bull';
import { isLinksOrLTAR } from '../../../../../../nocodb-sdk/src'
import extractRolesObj from '../../../../utils/extractRolesObj';
import { AttachmentsService } from '../../../../services/attachments.service';
import { ColumnsService } from '../../../../services/columns.service';
@ -270,7 +271,7 @@ export class AtImportProcessor {
// base mapping table
const aTblNcTypeMap = {
foreignKey: UITypes.LinkToAnotherRecord,
foreignKey: UITypes.Links,
text: UITypes.SingleLineText,
multilineText: UITypes.LongText,
richText: UITypes.LongText,
@ -785,7 +786,7 @@ export class AtImportProcessor {
const ncTbl: any = await this.columnsService.columnAdd({
tableId: srcTableId,
column: {
uidt: UITypes.LinkToAnotherRecord,
uidt: UITypes.Links,
title: ncName.title,
column_name: ncName.column_name,
parentId: srcTableId,
@ -867,14 +868,14 @@ export class AtImportProcessor {
updateMigrationSkipLog(
parentTblSchema?.title,
ncLinkMappingTable[x].nc.title,
UITypes.LinkToAnotherRecord,
UITypes.Links,
'Link error',
);
continue;
}
// hack // fix me
if (parentLinkColumn.uidt !== 'LinkToAnotherRecord') {
if (!isLinksOrLTAR(parentLinkColumn)) {
parentLinkColumn = parentTblSchema.columns.find(
(col) => col.title === ncLinkMappingTable[x].nc.title + '_2',
);
@ -888,7 +889,7 @@ export class AtImportProcessor {
//
childLinkColumn = childTblSchema.columns.find(
(col) =>
col.uidt === UITypes.LinkToAnotherRecord &&
isLinksOrLTAR(col) &&
col.colOptions.fk_child_column_id ===
parentLinkColumn.colOptions.fk_child_column_id &&
col.colOptions.fk_parent_column_id ===
@ -900,7 +901,7 @@ export class AtImportProcessor {
//
childLinkColumn = childTblSchema.columns.find(
(col) =>
col.uidt === UITypes.LinkToAnotherRecord &&
isLinksOrLTAR(col) &&
col.colOptions.fk_child_column_id ===
parentLinkColumn.colOptions.fk_parent_column_id &&
col.colOptions.fk_parent_column_id ===
@ -1431,7 +1432,7 @@ export class AtImportProcessor {
// always process LTAR, Lookup, and Rollup columns as we delete the key after processing
if (
!value &&
dt !== UITypes.LinkToAnotherRecord &&
!isLinksOrLTAR(dt) &&
dt !== UITypes.Lookup &&
dt !== UITypes.Rollup
) {
@ -1450,6 +1451,7 @@ export class AtImportProcessor {
// we will pick up LTAR once all table data's are in place
case UITypes.LinkToAnotherRecord:
case UITypes.Links:
if (storeLinks) {
if (ncLinkDataStore[table.title][record.id] === undefined)
ncLinkDataStore[table.title][record.id] = {
@ -1971,7 +1973,7 @@ export class AtImportProcessor {
const ncTbl = await nc_getTableSchema(aTblSchema[idx].name);
const linkColumn = ncTbl.columns.filter(
(x) => x.uidt === UITypes.LinkToAnotherRecord,
(x) => isLinksOrLTAR(x)
);
const lookup = ncTbl.columns.filter((x) => x.uidt === UITypes.Lookup);
const rollup = ncTbl.columns.filter((x) => x.uidt === UITypes.Rollup);

Loading…
Cancel
Save