【发布时间】:2022-01-26 05:36:38
【问题描述】:
我正在尝试让柴油板条箱与 SQLite 一起使用,但离开了入门指南,它似乎不适用于 sqlite。
适用于 postgres 但不适用于 sqlite 的代码
diesel::insert_into(schema::subscriptions::table)
.values(&new_subscription)
.get_result(&connection)
.expect("Error saving new subscription")
错误
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`
我可以在 the documentation 中看到一些关于柴油退货条款的参考资料,但我不完全确定应该将其更改为什么才能使其正常工作。
【问题讨论】:
-
正如链接文档所述,sqlite 后端不支持 RETURNING 子句。您可能必须将
get_results替换为execute才能执行 INSERT,然后发出查询以检索插入的记录。 -
是的,这似乎是解决方案
-
你看过示例代码的SQLite version吗?
-
是的,我找到了解决方案。认为为其他人发布帖子仍然有用,因为确切的错误消息并没有真正显示在 google 上(此帖子是现在搜索时的第二个结果)。
-
@Qwertie ,它确实对我有用,我想对其他人也有用:),也许你可以为你的问题添加一个答案。
标签: sqlite rust rust-diesel