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

Json type in shema causes Error #203

Closed JK2Kgit closed 1 year ago

JK2Kgit commented 1 year ago

Schema

generator client {
  provider = "cargo +nightly run --bin prisma_cli --"
  output   = "../../tests/src/prisma.rs"
}

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

model test {
  id   String @id
  data Json
}

Causes 9 compile errors, with the only difference being the code line numbers

error[E0433]: failed to resolve: use of undeclared crate or module `serde_json`
   --> tests/src/prisma.rs:255:61
    |
255 |                     ::prisma_client_rust::PrismaValue::Json(serde_json::to_string(&value).unwrap()),
    |                                                             ^^^^^^^^^^ use of undeclared crate or module `serde_json`

dependencies

[dependencies]
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust", default-features = false, features=["postgresql"], rev = "a0fb19d25d6869c6398a338e5228d80c81a8c354"}
serde = {version = "^1", features=["derive"]}

Checked on:

Possibly fixable by changing code line returned with errors in similar way

::prisma_client_rust::PrismaValue::Json(prisma_client_rust::serde_json::to_string(&value).unwrap()),

Or importing


pub mod test {
    use prisma_client_rust::serde_json;

Possible workaround for now is adding serde_json to dependencies.

Brendonovich commented 1 year ago

Looks like I'm not fully qualifying it, will fix soon.

Brendonovich commented 1 year ago

@JK2Kgit Should be fixed by rev = "37e872b697790b988df3742e900bee1e904da9fb"

JK2Kgit commented 1 year ago

@Brendonovich Yes it is a fix Thanks now i will be waiting for 0.6.4