Skip to content

Commit

Permalink
Derive PartialEq for Update structs
Browse files Browse the repository at this point in the history
To allow easy checks for "empty" updates, this change adds the PartialEq
derive to the generated Update structs. This allows comparison with
`Default::default()` to check if an update is empty.

Fixes: #117
  • Loading branch information
longsleep committed Nov 6, 2023
1 parent 6d6a4e2 commit 1c1b9ab
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ pub mod derives {
pub const SELECTABLE: &str = "Selectable";
pub const IDENTIFIABLE: &str = "Identifiable";
pub const ASSOCIATIONS: &str = "Associations";
pub const PARTIALEQ: &str = "PartialEq";
}

impl<'a> Struct<'a> {
Expand Down Expand Up @@ -200,6 +201,7 @@ impl<'a> Struct<'a> {
.all(|f| self.table.primary_key_column_names().contains(&f.name))
{
derives_vec.push(derives::ASCHANGESET);
derives_vec.push(derives::PARTIALEQ);
}

derives_vec.push(derives::DEFAULT);
Expand Down

0 comments on commit 1c1b9ab

Please sign in to comment.