Customise Display impl of ContactId

This brings the Display of ContactId in line with those of ChatId etc,
which is a bit clearer is logs and such places.

It also updates an SQL query to rely on the ToSql impl of ContactId
rather than it's Display when building the query.
This commit is contained in:
Floris Bruynooghe
2022-03-16 13:05:13 +01:00
committed by bjoern
parent 64927190bd
commit cc55be0b0a
3 changed files with 42 additions and 28 deletions

View File

@@ -797,6 +797,19 @@ async fn prune_tombstones(sql: &Sql) -> Result<()> {
Ok(())
}
/// Helper function to return comma-separated sequence of `?` chars.
///
/// Use this together with [`rusqlite::ParamsFromIter`] to use dynamically generated
/// parameter lists.
pub fn repeat_vars(count: usize) -> Result<String> {
if count == 0 {
bail!("Must have at least one repeat variable");
}
let mut s = "?,".repeat(count);
s.pop(); // Remove trailing comma
Ok(s)
}
#[cfg(test)]
mod tests {
use async_std::channel;