changing profile id to schema in the whole project
This commit is contained in:
@@ -20,23 +20,22 @@ pub async fn qualify_table_name(
|
||||
let definition_exists = sqlx::query!(
|
||||
r#"SELECT EXISTS (
|
||||
SELECT 1 FROM table_definitions td
|
||||
JOIN profiles p ON td.profile_id = p.id
|
||||
WHERE p.name = $1 AND td.table_name = $2
|
||||
JOIN schemas s ON td.schema_id = s.id
|
||||
WHERE s.name = $1 AND td.table_name = $2
|
||||
)"#,
|
||||
profile_name,
|
||||
table_name
|
||||
)
|
||||
.fetch_one(db_pool)
|
||||
.fetch_one(db_pool)
|
||||
.await
|
||||
.map_err(|e| Status::internal(format!("Schema lookup failed: {}", e)))?
|
||||
.exists
|
||||
.unwrap_or(false);
|
||||
|
||||
if definition_exists {
|
||||
// It's a user-defined table, so it lives in 'gen'.
|
||||
Ok(format!("gen.\"{}\"", table_name))
|
||||
Ok(format!("{}.\"{}\"", profile_name, table_name))
|
||||
} else {
|
||||
// It's not a user-defined table, so it must be a system table in 'public'.
|
||||
// It's not a user-defined table, so it must be a system table in 'public.
|
||||
Ok(format!("\"{}\"", table_name))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user