feat(csv-loader): support references in addition to strings for foreignKey reverse ref

This commit is contained in:
hyper 2026-04-19 18:58:52 +08:00
parent 9a2db5edb6
commit 5f941aba10
1 changed files with 8 additions and 1 deletions

View File

@ -352,7 +352,14 @@ function resolveReverseReference(
currentFilePath,
);
const pkStr = String(pkValue);
return refTable.filter((row) => String(row[schema.foreignKey]) === pkStr);
return refTable.filter((row) => {
const fkValue = row[schema.foreignKey];
const fkStr =
fkValue !== null && fkValue !== undefined && typeof fkValue === "object"
? String((fkValue as Record<string, unknown>)[defaultPrimaryKey])
: String(fkValue);
return fkStr === pkStr;
});
}
function resolveNestedReferences(