-1

我正在关注来自 rusqlite git hub https://github.com/rusqlite/rusqlite/blob/master/src/vtab/array.rs#L206的示例。我有完全相同的代码,但我得到了编译错误

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

代码片段如下。ids 是字符串的 Vec

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)?
        })
    });
4

1 回答 1

0

我必须在 toml 文件的功能中添加“数组”。

于 2021-09-18T04:04:58.273 回答