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

@@ -25,21 +25,21 @@ pub async fn post_table_data(
let table_name = request.table_name;
// 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)
@@ -132,7 +132,8 @@ pub async fn post_table_data(
let context = SteelContext {
current_table: table_name.clone(),
profile_id,
schema_id,
schema_name: profile_name.clone(),
row_data: string_data_for_scripts.clone(),
db_pool: Arc::new(db_pool.clone()),
};