Skip to content

CompatibleType<SampleEntity, _>` is not satisfied for Bytes newtype #4426

Answered by weiznich
Jaltaire asked this question in Q&A
Discussion options

You must be logged in to vote

The error message already contains the first hint on how to fix that problem:

= note: consider using `#[derive(Selectable)]` or #[derive(QueryableByName)] + `#[diesel(check_for_backend(_))]` 
          on your struct `SampleEntity` and in your query `.select(SampleEntity::as_select())` to get a better error message

Doing that gives you the following error message:

error[E0277]: cannot deserialize a value of the database type `diesel::sql_types::Binary` as `bytes::Bytes`
  --> src/sample.rs:12:19
   |
12 |     pub contents: Contents,
   |                   ^^^^^^^^ the trait `FromSql<diesel::sql_types::Binary, Pg>` is not implemented for `bytes::Bytes`, which is required by `Contents: F…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Jaltaire
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants