Brendonovich / prisma-client-rust

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

Generated enums are not brought into scope in prisma.rs #212

Closed westernwontons closed 1 year ago

westernwontons commented 1 year ago

Generating the client for MongoDB doesn't bring enums into scope. I can manually import them and the client seems to be working fine (haven't fully tested tho).

For example:

image

Is this a bug?

alakhpc commented 1 year ago

running into the same issue with postgresql

reproduction:

datasource db {
    provider = "postgresql"
    url      = env("PRISMA_DATABASE_URL")
}

generator rust {
    provider = "cargo prisma"
    output   = "./src/prisma.rs"
}

enum ProductType {
    New
}

model Test {
    id           Int         @id
    product_type ProductType
}
error[E0412]: cannot find type `ProductType` in this scope
   --> src/prisma.rs:653:23
    |
653 |             InVec(Vec<ProductType>),
    |                       ^^^^^^^^^^^ not found in this scope
    |
help: consider importing this enum
    |
596 |         use crate::prisma::ProductType;
    |
jqphu commented 1 year ago

I'm also running into this using postgresql. Currently just working around it by manually bringing in the enum into scope.

Brendonovich commented 1 year ago

Duplicate of #197. Has been fixed on 1.6.4 branch.

jqphu commented 1 year ago

Awesome, just switched to using 0.6.4 branch and it works perfectly. Thanks!