Return an error instead of panicing when parameter count is wron… (#675)

Fixes #671
This commit is contained in:
Thom Chiovoloni
2020-04-06 12:47:35 -07:00
committed by GitHub
parent 6f6f7ffd9f
commit 0394e114d0
2 changed files with 19 additions and 7 deletions

View File

@@ -450,13 +450,11 @@ impl Statement<'_> {
}
self.bind_parameter(&p, index)?;
}
assert_eq!(
index, expected,
"incorrect number of parameters: expected {}, got {}",
expected, index
);
Ok(())
if index != expected {
Err(Error::InvalidParameterCount(expected, index))
} else {
Ok(())
}
}
fn bind_parameters_named(&mut self, params: &[(&str, &dyn ToSql)]) -> Result<()> {