pub trait ComposerConnection {
type Value;
type Statement;
type Error: From<Error>;
// Required method
fn compose(
&self,
composer: &Composer,
template: &Template,
values: BTreeMap<String, Vec<Self::Value>>,
) -> Result<(Self::Statement, Vec<Self::Value>), Self::Error>;
}Expand description
Trait for synchronous database drivers that can compose and prepare SQL.
Each driver crate implements this for its connection type, providing the bridge between sql-composer’s template system and the database’s API.
§Example
ⓘ
let (sql, values) = conn.compose(&composer, &template, bind_values!("id" => [1]))?;
let mut stmt = conn.prepare(&sql)?;
let rows = stmt.query_map(params_from_iter(values.iter().map(|v| v.as_ref())), |row| { ... })?;Required Associated Types§
Required Methods§
Sourcefn compose(
&self,
composer: &Composer,
template: &Template,
values: BTreeMap<String, Vec<Self::Value>>,
) -> Result<(Self::Statement, Vec<Self::Value>), Self::Error>
fn compose( &self, composer: &Composer, template: &Template, values: BTreeMap<String, Vec<Self::Value>>, ) -> Result<(Self::Statement, Vec<Self::Value>), Self::Error>
Compose a template with bind values, returning prepared SQL and ordered values.
Takes the composer, a parsed template, and a map of named bind values. Resolves bind parameter order and returns the SQL string with ordered values ready for execution.