mirror of
https://github.com/isar/rusqlite.git
synced 2025-11-01 14:28:55 +08:00
Use ?NNN format instead of ?
https://sqlite.org/lang_expr.html#parameters > But because it is easy to miscount the question marks, the use of this parameter format is discouraged. Programmers are encouraged to use one of the symbolic formats below or the ?NNN format above instead.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
//! let v = [1i64, 2, 3, 4];
|
||||
//! // Note: A `Rc<Vec<Value>>` must be used as the parameter.
|
||||
//! let values = Rc::new(v.iter().copied().map(Value::from).collect::<Vec<Value>>());
|
||||
//! let mut stmt = db.prepare("SELECT value from rarray(?);")?;
|
||||
//! let mut stmt = db.prepare("SELECT value from rarray(?1);")?;
|
||||
//! let rows = stmt.query_map([values], |row| row.get::<_, i64>(0))?;
|
||||
//! for value in rows {
|
||||
//! println!("{}", value?);
|
||||
@@ -206,7 +206,7 @@ mod test {
|
||||
let values: Vec<Value> = v.into_iter().map(Value::from).collect();
|
||||
let ptr = Rc::new(values);
|
||||
{
|
||||
let mut stmt = db.prepare("SELECT value from rarray(?);")?;
|
||||
let mut stmt = db.prepare("SELECT value from rarray(?1);")?;
|
||||
|
||||
let rows = stmt.query_map([&ptr], |row| row.get::<_, i64>(0))?;
|
||||
assert_eq!(2, Rc::strong_count(&ptr));
|
||||
|
||||
@@ -286,13 +286,13 @@ mod test {
|
||||
let mut stmt = db.prepare("SELECT * FROM log;")?;
|
||||
let mut rows = stmt.query([])?;
|
||||
while rows.next()?.is_some() {}
|
||||
db.execute("DELETE FROM log WHERE a = ?", ["a1"])?;
|
||||
db.execute("DELETE FROM log WHERE a = ?1", ["a1"])?;
|
||||
db.execute(
|
||||
"INSERT INTO log (a, b, c) VALUES (?, ?, ?)",
|
||||
"INSERT INTO log (a, b, c) VALUES (?1, ?2, ?3)",
|
||||
["a", "b", "c"],
|
||||
)?;
|
||||
db.execute(
|
||||
"UPDATE log SET b = ?, c = ? WHERE a = ?",
|
||||
"UPDATE log SET b = ?1, c = ?2 WHERE a = ?3",
|
||||
["bn", "cn", "a1"],
|
||||
)?;
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user