more fixes

This commit is contained in:
filipriec
2025-06-21 21:43:39 +02:00
parent 06d98aab5c
commit 87b9f6ab87
3 changed files with 77 additions and 19 deletions

View File

@@ -203,8 +203,17 @@ async fn execute_table_definition(
.map_err(|e| Status::internal(format!("Schema creation failed: {}", e)))?;
let mut links = Vec::new();
let mut seen_tables = std::collections::HashSet::new();
for link in request.links.drain(..) {
// CHANGED: Use schema_id instead of profile_id
// Check for duplicate link
if !seen_tables.insert(link.linked_table_name.clone()) {
return Err(Status::invalid_argument(format!(
"Duplicate link to table '{}'",
link.linked_table_name
)));
}
let linked_table = sqlx::query!(
"SELECT id FROM table_definitions
WHERE schema_id = $1 AND table_name = $2",