Expand description
Profile-specific file override resolution.
Files can be named name#<profile>.sql to override name.sql when a
particular profile is active. The # delimiter is split on the last
occurrence (rsplit_once).
ยงResolution Algorithm
- Parse each file stem via
parse_file_stemusingrsplit_once('#')to separate(object_name, profile). Files without#(or with an empty object/profile part) are treated as the default (no profile). - Group files by object name into
ObjectFiles, recording the default file and any profile-specific overrides. Duplicates within the same group (e.g., two defaults, or two overrides for the same profile) are rejected withLoadError::DuplicateProfileObject.
Callers select the active variant themselves by checking
overrides.get(profile).or(default.as_ref()).
Key Insight: # cannot appear in a SQL identifier, so a well-formed
variant filename contains exactly one #. This lets object names freely
contain underscores: my_pg_conn#staging โ ("my_pg_conn", "staging").
Structsยง
- Object
Files ๐ - All files for a single object name, grouped by profile.
Functionsยง
- collect_
all_ ๐sql_ files - Collect all
.sqlfiles from a directory grouped by object name without resolving. - parse_
file_ ๐stem - Split a file stem into
(object_name, optional_profile).