0

I'm following the example from the rusqlite git hub https://github.com/rusqlite/rusqlite/blob/master/src/vtab/array.rs#L206. I have the exact same code but I get the compile error

the trait bound `std::vec::Vec<rusqlite::types::Value>: rusqlite::ToSql` is not satisfied

A snippet of the code is below. ids is a Vec of String

let intValues:Vec<i64> = ids.into_iter().map(|s| s.parse::<i64>().expect("Id Parse error.")).collect();
let values:Vec<rusqlite::types::Value> = intValues.into_iter().map(rusqlite::types::Value::from).collect();
let ptr = std::rc::Rc::new(values);
let mut statement = db_connection
    .prepare("select * from item where id in rarray(?);")
    .expect("Failed to prepare second query.");
let results = statement

// This is the error line
    .query_map(&[&ptr], |row| {
        Ok(database::ItemData {
            id: row.get(0)?,
            name: row.get(1)?,
            time_to_prepare: row.get(2)?
        })
    });
Dave
  • 179
  • 1
  • 1
  • 7
  • you don't show the real code https://docs.rs/rusqlite/0.25.3/rusqlite/vtab/array/type.Array.html => `let ptr = std::rc::Rc::new(values);` => `the trait bound std::vec::Vec: rusqlite::ToSql`. Not possible. Check version, checke everything twice. – Stargateur Sep 18 '21 at 02:10
  • I'm not sure what you are saying. This is my real code and this is the error I'm getting. I checked the version before posting here. – Dave Sep 18 '21 at 03:46
  • What is the difference between carray and rarray? I just found doc for "carray": https://sqlite.org/carray.html linked in the Rusqlite documentation of array. – Felipe May 08 '23 at 16:12

1 Answers1

1

I had to add "array" to the feature in the toml file.

Dave
  • 179
  • 1
  • 1
  • 7