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

Prisma enum generation broken #197

Closed styxpilled closed 1 year ago

styxpilled commented 1 year ago

When using a prisma enum, the generated rust code includes an E0412 error. Prisma enum example:

model Thing {
  id   Int       @id
  kind ThingKind
}

enum ThingKind {
  Foo
  Bar
  Creature
}

The generated rust enum in _prisma > read_filters gives a cannot find type ThingKind in this scope not found in this scope rustc(E0412) error.

pub enum ThingKindFilter {
    InVec(Vec<ThingKind>),
    NotInVec(Vec<ThingKind>),
    Not(ThingKind),
}

Adding use crate::prisma::ObjectKind; above the rust enum, per the compiler suggestion, fixes the issue.

Brendonovich commented 1 year ago

@styxpilled @codemaster138 can you try using rev = "a0fb19d25d6869c6398a338e5228d80c81a8c354" and see if it fixes the problem? It's not a complete nice fix but it should get the job done for now.

codemaster138 commented 1 year ago

@Brendonovich yeah, that seems to have fixed the issue. Thanks for handling this so quickly!