pub struct Composer {
pub dialect: Dialect,
pub search_paths: Vec<PathBuf>,
pub mock_tables: HashMap<String, MockTable>,
}Expand description
Composes parsed templates into final SQL.
Handles dialect-specific placeholder generation, compose reference resolution, and mock table substitution.
Fields§
§dialect: DialectThe target database dialect for placeholder syntax.
search_paths: Vec<PathBuf>Directories to search for template files referenced by :compose().
mock_tables: HashMap<String, MockTable>Mock tables for test data substitution.
Implementations§
Source§impl Composer
impl Composer
Sourcepub fn add_search_path(&mut self, path: PathBuf)
pub fn add_search_path(&mut self, path: PathBuf)
Add a search path for resolving compose references.
Sourcepub fn add_mock_table(&mut self, mock: MockTable)
pub fn add_mock_table(&mut self, mock: MockTable)
Register a mock table for test data substitution.
Sourcepub fn compose(&self, template: &Template) -> Result<ComposedSql>
pub fn compose(&self, template: &Template) -> Result<ComposedSql>
Compose a template into final SQL with placeholders.
Sourcepub fn compose_with_values<V>(
&self,
template: &Template,
values: &BTreeMap<String, Vec<V>>,
) -> Result<ComposedSql>
pub fn compose_with_values<V>( &self, template: &Template, values: &BTreeMap<String, Vec<V>>, ) -> Result<ComposedSql>
Compose a template with value counts, expanding multi-value bindings into multiple placeholders.
When a :bind(name) has multiple values in the map, this method emits
one placeholder per value (e.g. $1, $2, $3 for 3 values), and repeats
the bind name in bind_params for each. This enables IN clauses:
SELECT * FROM users WHERE id IN (:bind(ids))
-- with ids=[10, 20, 30] becomes:
SELECT * FROM users WHERE id IN ($1, $2, $3)
-- bind_params = ["ids", "ids", "ids"]For bindings with only one value, behavior is identical to Composer::compose().