Skip to main content

discover_project

Function discover_project 

Source
fn discover_project(
    fs: &FileSystem,
    root: &Path,
    profile_suffix: Option<&str>,
    variables: &BTreeMap<String, String>,
    profile_set: bool,
    db: &mut BuildArtifact,
) -> Result<Discovery, ProjectError>
Expand description

Walk the models/ directory tree and collect everything needed for compilation.

The directory structure follows the convention:

models/
  <database>/               ← directory name = database name
    <database>.sql          ← optional database-level mod file (grants, comments)
    <schema>/               ← directory name = schema name
      <schema>.sql          ← optional schema-level mod file
      <object>.sql          ← one file per database object
      <object>#<profile>.sql ← optional profile variant override

For each database directory:

  • Computes the effective database name (original + profile suffix if active).
  • Parses and validates database and schema mod files.
  • Collects all object file variants into ObjectDescriptors.
  • Builds the db_name_map for cross-database reference rewriting.

Returns a Discovery or fails with accumulated validation errors.