Skip to content

Commit

Permalink
Add a compile test to verify that the it's not possible to mix serial…
Browse files Browse the repository at this point in the history
…ize_as + embed
  • Loading branch information
weiznich committed Aug 28, 2024
1 parent 9c68a8a commit 456aefc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions diesel_compile_tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ table! {
}
}

#[derive(Insertable)]
#[derive(Insertable, AsChangeset)]
#[diesel(table_name = users)]
struct NameAndHairColor<'a> {
name: &'a str,
Expand All @@ -24,4 +24,13 @@ struct User<'a> {
name_and_hair_color: NameAndHairColor<'a>,
}

#[derive(AsChangeset)]
#[diesel(table_name = users)]
struct UserChangeSet<'a> {
id: i32,
#[diesel(embed, serialize_as = SomeType)]
// to test the compile error, this type doesn't need to exist
name_and_hair_color: NameAndHairColor<'a>,
}

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ error: `#[diesel(embed)]` cannot be combined with `#[diesel(serialize_as)]`
|
22 | #[diesel(embed, serialize_as = SomeType)]
| ^^^^^^

error: `#[diesel(embed)]` cannot be combined with `#[diesel(serialize_as)]`
--> tests/fail/derive/embed_and_serialize_as_cannot_be_mixed.rs:31:7
|
31 | #[diesel(embed, serialize_as = SomeType)]
| ^^^^^^

0 comments on commit 456aefc

Please sign in to comment.