Skip to main content

required_pg_search_path

Function required_pg_search_path 

Source
pub fn required_pg_search_path(schema_info: &SchemaInfo) -> Vec<String>
Expand description

Compute the schemas that must appear in PostgreSQL’s search_path for the generated code to resolve every emitted unqualified type_name.

Returns the deduplicated, sorted list of non-default schemas hosting enums/composites/domains in schema_info. The caller can feed this into the pool’s connect-hook, e.g.:

let schemas = sqlx_gen::codegen::required_pg_search_path(&info).join(", ");
sqlx::query(&format!("SET search_path TO public, {}", schemas))
    .execute(&pool).await?;