trait diesel::Insertable is not implemented #4040
Unanswered
prsabahrami
asked this question in
Q&A
Replies: 1 comment
-
It seems like your question is missing important details as I cannot reproduce the error if I fill in the missing pieces. For reference the following code works for me: use diesel::prelude::*;
table! {
attachment_blobs(key) {
key -> Text,
file_name -> Text,
content_type -> Nullable<Text>,
byte_size -> BigInt,
checksum -> Text,
service_name -> Text,
}
}
#[derive(Debug, Clone, Insertable, AsChangeset)]
#[diesel(table_name = attachment_blobs)]
pub struct AttachmentBlobChangeset {
pub key: String,
pub file_name: String,
pub content_type: Option<String>,
pub byte_size: i64,
pub checksum: String,
pub service_name: String,
}
#[derive(Queryable)]
struct AttachmentBlob {
pub key: String,
pub file_name: String,
pub content_type: Option<String>,
pub byte_size: i64,
pub checksum: String,
pub service_name: String,
}
impl AttachmentBlob {
pub fn create(db: &mut PgConnection, item: &AttachmentBlobChangeset) -> QueryResult<Self> {
use crate::attachment_blobs::dsl::*;
diesel::insert_into(attachment_blobs)
.values(item)
.get_result::<AttachmentBlob>(db)
}
} If you still have this problem I would suggest that you put together a complete reproducible example (i.e. something where someone can just run |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey!
I'm pretty new to Diesel and I wanted to run this below piece of code and I got an error. Was wondering if anyone has any idea on why this is happening?
As you can see the Insertable is implemented for
AttachmentBlobChangeset
using derive but when I run this code, I get the below error:which is saying the trait is not implemented whereas it is.
It is also important to note that the whole code is written in attachment_blob.rs inside of services folder.
Any idea?
Beta Was this translation helpful? Give feedback.
All reactions