compiled with the profile to be schemas

This commit is contained in:
filipriec
2025-06-21 10:37:37 +02:00
parent 63f1b4da2e
commit 4e29d0084f
8 changed files with 42 additions and 40 deletions

View File

@@ -15,21 +15,21 @@ pub async fn get_table_data(
let record_id = request.id;
// Lookup profile
let profile = sqlx::query!(
"SELECT id FROM profiles WHERE name = $1",
let schema = sqlx::query!(
"SELECT id FROM schemas WHERE name = $1",
profile_name
)
.fetch_optional(db_pool)
.await
.map_err(|e| Status::internal(format!("Profile lookup error: {}", e)))?;
let profile_id = profile.ok_or_else(|| Status::not_found("Profile not found"))?.id;
let schema_id = schema.ok_or_else(|| Status::not_found("Profile not found"))?.id;
// Lookup table_definition
let table_def = sqlx::query!(
r#"SELECT id, columns FROM table_definitions
WHERE profile_id = $1 AND table_name = $2"#,
profile_id,
WHERE schema_id = $1 AND table_name = $2"#,
schema_id,
table_name
)
.fetch_optional(db_pool)