“‘Sqlite’未实现‘SupportsReturningClause’特征”

Qwe*_*tie 6 sqlite rust rust-diesel

我正在尝试让柴油箱与 SQLite 一起使用,但是脱离了入门指南,它似乎不适用于 sqlite。

该代码适用于 postgres 但不适用于 sqlite

  diesel::insert_into(schema::subscriptions::table)
      .values(&new_subscription)
      .get_result(&connection)
      .expect("Error saving new subscription")
Run Code Online (Sandbox Code Playgroud)

错误

error[E0277]: the trait bound `Sqlite: SupportsReturningClause` is not satisfied
  --> src/responder.rs:41:12
   |
41 |           .get_result(&connection)
   |            ^^^^^^^^^^ the trait `SupportsReturningClause` is not implemented for `Sqlite`
Run Code Online (Sandbox Code Playgroud)

我可以在文档中看到一些有关柴油退货条款的参考资料,但我不完全确定应该将其更改为什么才能使其正常工作。

Qwe*_*tie 8

使用execute而不是get_results适用于 SQLite。但这不会返回查询的结果,因此必须运行第二个查询才能获取更新的值。