the base name and linked name bug fixed to match for the id
This commit is contained in:
@@ -190,9 +190,20 @@ fn generate_table_sql(
|
|||||||
];
|
];
|
||||||
|
|
||||||
if let Some(linked) = linked_table {
|
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!(
|
system_indexes.push(format!(
|
||||||
"CREATE INDEX idx_{}_{}_id ON \"{}\" (\"{}_id\")",
|
"CREATE INDEX idx_{}_{}_id ON \"{}\" (\"{}_id\")",
|
||||||
table_name, linked, table_name, linked
|
table_name, base_name, table_name, base_name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user