|
|
|
@ -314,7 +314,7 @@ export class AtImportProcessor {
|
|
|
|
|
const nc_getSanitizedColumnName = (table, name) => { |
|
|
|
|
let col_name = nc_sanitizeName(name); |
|
|
|
|
|
|
|
|
|
// truncate to 60 chars if character if exceeds above 50
|
|
|
|
|
// truncate to 50 chars if character if exceeds above 50
|
|
|
|
|
col_name = col_name?.slice(0, 50); |
|
|
|
|
|
|
|
|
|
// for knex, replace . with _
|
|
|
|
@ -327,27 +327,33 @@ export class AtImportProcessor {
|
|
|
|
|
const duplicateColumn = table.columns.find( |
|
|
|
|
(x) => x.column_name?.toLowerCase() === col_name?.toLowerCase(), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (duplicateTitle) { |
|
|
|
|
let iterator = 1; |
|
|
|
|
let tempAlias = col_alias; |
|
|
|
|
let suffix = 1; |
|
|
|
|
while ( |
|
|
|
|
table.columns.find( |
|
|
|
|
(x) => |
|
|
|
|
x.title?.toLowerCase() === |
|
|
|
|
`${col_alias}_${++iterator}`?.toLowerCase(), |
|
|
|
|
(x) => x.title?.toLowerCase() === tempAlias?.toLowerCase(), |
|
|
|
|
) |
|
|
|
|
) {} |
|
|
|
|
col_alias = `${col_alias}_${iterator}`; |
|
|
|
|
) { |
|
|
|
|
tempAlias = col_alias; |
|
|
|
|
tempAlias += `_${suffix++}`; |
|
|
|
|
} |
|
|
|
|
col_alias = tempAlias; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (duplicateColumn) { |
|
|
|
|
let iterator = 1; |
|
|
|
|
let tempName = col_name; |
|
|
|
|
let suffix = 1; |
|
|
|
|
while ( |
|
|
|
|
table.columns.find( |
|
|
|
|
(x) => |
|
|
|
|
x.column_name?.toLowerCase() === |
|
|
|
|
`${col_name}_${++iterator}`?.toLowerCase(), |
|
|
|
|
(x) => x.column_name?.toLowerCase() === tempName?.toLowerCase(), |
|
|
|
|
) |
|
|
|
|
) {} |
|
|
|
|
col_name = `${col_name}_${iterator}`; |
|
|
|
|
) { |
|
|
|
|
tempName = col_name; |
|
|
|
|
tempName += `_${suffix++}`; |
|
|
|
|
} |
|
|
|
|
col_name = tempName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|