mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-18 06:24:56 +01:00
Merge 'bindings/rust: don't panic if user provides invalid parameter' from Jussi Saurio
Now returns e.g.: ```rust SqlExecutionFailure( "Invalid argument supplied: Unknown parameter ':email' for query 'INSERT INTO users (email, created_at) VALUES (?, ?)'. Make sure you're using the correct parameter syntax - named: (:foo), positional: (?, ?)" ) ``` instead of unwrapping a None value and panicing Closes #3515
This commit is contained in:
@@ -482,7 +482,10 @@ impl Statement {
|
||||
params::Params::Named(values) => {
|
||||
for (name, value) in values.into_iter() {
|
||||
let mut stmt = self.inner.lock().unwrap();
|
||||
let i = stmt.parameters().index(name).unwrap();
|
||||
let i = stmt.parameters().index(&name).ok_or(
|
||||
turso_core::LimboError::InvalidArgument(
|
||||
format!("Unknown parameter '{name}' for query '{}'. Make sure you're using the correct parameter syntax - named: (:foo), positional: (?, ?)", stmt.get_sql())
|
||||
))?;
|
||||
stmt.bind_at(i, value.into());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user