Skipped unknown CSV columns
X-Lovable-Edit-ID: edt-6db05b6e-69a5-45bd-80ea-5f8573fd3512 Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
@@ -549,12 +549,34 @@ function ImportPage() {
|
||||
|
||||
const rawRows = parsed.data;
|
||||
const headers = parsed.meta.fields ?? [];
|
||||
// Build header → db column map
|
||||
// Allowed target columns = mapped alias targets + transform helper fields.
|
||||
// Anything else (unknown columns / missing schema) is silently skipped.
|
||||
const allowedTargets = new Set<string>([
|
||||
...Object.values(cfg.aliases),
|
||||
...(cfg.numeric ?? []),
|
||||
...(cfg.dateCols ?? []),
|
||||
...(cfg.datetimeCols ?? []),
|
||||
...(cfg.boolCols ?? []),
|
||||
...cfg.required,
|
||||
"external_id",
|
||||
"created_by",
|
||||
]);
|
||||
// Build header → db column map (only keep known targets)
|
||||
const headerMap: Record<string, string> = {};
|
||||
const unknownHeaders: string[] = [];
|
||||
for (const h of headers) {
|
||||
const n = norm(h);
|
||||
const target = cfg.aliases[n] ?? n;
|
||||
headerMap[h] = target;
|
||||
const target = cfg.aliases[n];
|
||||
if (target && allowedTargets.has(target)) {
|
||||
headerMap[h] = target;
|
||||
} else if (allowedTargets.has(n)) {
|
||||
headerMap[h] = n;
|
||||
} else {
|
||||
unknownHeaders.push(h);
|
||||
}
|
||||
}
|
||||
if (unknownHeaders.length > 0) {
|
||||
console.info(`[import:${cfg.key}] skipped unknown columns:`, unknownHeaders);
|
||||
}
|
||||
|
||||
const mapped: Row[] = [];
|
||||
|
||||
Reference in New Issue
Block a user