mirror of
https://github.com/chartdb/chartdb.git
synced 2026-04-26 12:20:16 -05:00
fix: correct relationship direction in metadata import (#1007)
This commit is contained in:
@@ -55,24 +55,27 @@ export const createRelationshipsFromMetadata = ({
|
||||
.length > 1;
|
||||
|
||||
if (sourceTable && targetTable && sourceField && targetField) {
|
||||
// In ForeignKeyInfo: schema/table/column = FK table, reference_* = PK table
|
||||
// In DBRelationship: source = referenced table (PK), target = FK table
|
||||
// So we swap them here
|
||||
const sourceCardinality = determineCardinality(
|
||||
sourceField,
|
||||
isSourceTablePKComplex
|
||||
);
|
||||
const targetCardinality = determineCardinality(
|
||||
targetField,
|
||||
isTargetTablePKComplex
|
||||
);
|
||||
const targetCardinality = determineCardinality(
|
||||
sourceField,
|
||||
isSourceTablePKComplex
|
||||
);
|
||||
|
||||
return {
|
||||
id: generateId(),
|
||||
name: fk.foreign_key_name,
|
||||
sourceSchema: schema,
|
||||
targetSchema: targetSchema,
|
||||
sourceTableId: sourceTable.id,
|
||||
targetTableId: targetTable.id,
|
||||
sourceFieldId: sourceField.id,
|
||||
targetFieldId: targetField.id,
|
||||
sourceSchema: targetSchema,
|
||||
targetSchema: schema,
|
||||
sourceTableId: targetTable.id,
|
||||
targetTableId: sourceTable.id,
|
||||
sourceFieldId: targetField.id,
|
||||
targetFieldId: sourceField.id,
|
||||
sourceCardinality,
|
||||
targetCardinality,
|
||||
createdAt: Date.now(),
|
||||
|
||||
Reference in New Issue
Block a user