the base name and linked name bug fixed to match for the id

This commit is contained in:
filipriec
2025-03-01 21:31:42 +01:00
parent 93ce33c840
commit f0faff53bb

View File

@@ -190,9 +190,20 @@ fn generate_table_sql(
];
if let Some(linked) = linked_table {
let parts: Vec<&str> = linked.splitn(3, '_').collect();
let base_name = parts.get(2).unwrap_or(&linked);
system_columns.push(
format!("\"{}_id\" BIGINT NOT NULL REFERENCES \"{}\"(id)",
base_name,
linked
)
);
// FIXED: Use base_name instead of linked
system_indexes.push(format!(
"CREATE INDEX idx_{}_{}_id ON \"{}\" (\"{}_id\")",
table_name, linked, table_name, linked
table_name, base_name, table_name, base_name
));
}