Brendonovich / prisma-client-rust

Type-safe database access for Rust
https://prisma.brendonovich.dev
Apache License 2.0
1.8k stars 104 forks source link

User Prisma enums don't derive PartialEq #217

Closed styxpilled closed 1 year ago

styxpilled commented 1 year ago

Comparing enums generated from Prisma enums is currently a bit annoying since you can't compare them directly with ==, and matching them indents your code more. I feel like they should derive PartialEq and Eq.

enum Stuff {
  ONE
  TWO
  THREE
}
if thing == Stuff::One /* binary operation `==` cannot be applied to type `prisma::Thing`  */ {
    // ...
}

Without it, the workaround is to use match or convert the values to a string with .to_string() and compare that.

Brendonovich commented 1 year ago

That's a good point, in the meantime I'd suggest using matches!.

Brendonovich commented 1 year ago

@styxpilled Does using rev = "81fa36256e7cfab4c83128a5c3a1eaf2f1d55bcb" instead of tag = "0.6.3" work for you?

styxpilled commented 1 year ago

Yeap, that works!