Browse Source

Merge pull request #2369 from nocodb/fix/sync-duplicate-column

fix: sync duplicate column_name after sanitize
pull/2368/head
navi 2 years ago committed by GitHub
parent
commit
c689bf1e79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      packages/nocodb/src/lib/meta/api/sync/helpers/job.ts

9
packages/nocodb/src/lib/meta/api/sync/helpers/job.ts

@ -211,14 +211,15 @@ export default async (
const col_alias = name.trim().replace(/\./g, '_');
// check if already a column exists with same name?
const duplicateColumn = table.columns.find(x => x.title === col_alias);
if (duplicateColumn) {
if (enableErrorLogs) console.log(`## Duplicate ${col_alias}`);
const duplicateTitle = table.columns.find(x => x.title?.toLowerCase() === col_alias?.toLowerCase());
const duplicateColumn = table.columns.find(x => x.column_name?.toLowerCase() === col_name?.toLowerCase());
if (duplicateTitle) {
if (enableErrorLogs) console.log(`## Duplicate title ${col_alias}`);
}
return {
// kludge: error observed in Nc with space around column-name
title: col_alias + (duplicateColumn ? '_2' : ''),
title: col_alias + (duplicateTitle ? '_2' : ''),
column_name: col_name + (duplicateColumn ? '_2' : '')
};
}

Loading…
Cancel
Save