Brendonovich / prisma-client-rust

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

Error: Trait bound not satisfied #379

Closed Raduc4 closed 10 months ago

Raduc4 commented 10 months ago

OS- Arch Linux Rust - 1.71.0 environment - Tauri

I'm getting this error in db.rs that is generated wrong. I hope it is because of the features and I'd appreciate a hint on this. Thank you.

schema.prisma

generator client {
  provider    = "cargo prisma"
  output      = "../src/db.rs"
  module_path = "crate:db"
}

datasource db {
  provider = "sqlite"
  url      = "file:dev.db"
}

model Post {
    id      Int    @id @default(autoincrement())
    title   String
    content String
}

Cargo.toml

specta = {version = "=2.0.0-rc.1",  features = ["functions"] }
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.6.8", default-features=false, features = ["rspc", "sqlite-create-many", "migrations", "sqlite", "specta"] }
tauri-specta = { git = "https://github.com/oscartbeaumont/tauri-specta", branch = "v2", default-features = false, features = ["typescript"] }

prisma-cli/Cargo.toml

[dependencies]
prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust", default-features = false, features = ["rspc",
    "sqlite-create-many",
    "migrations",
    "sqlite",
  "specta"
  ] }
   Compiling citadel-workspace v0.1.0 (/home/alu/profects/rust/citadel-workspace/src-tauri)
error[E0433]: failed to resolve: could not find `filter_factory` in `macros`
   --> src/db.rs:641:40
    |
641 |     :: prisma_client_rust :: macros :: filter_factory ! (_post_filter , crate : db :: post , [(id , Scalar) , (title , Scalar) , (content...
    |                                        ^^^^^^^^^^^^^^ could not find `filter_factory` in `macros`

error[E0412]: cannot find type `CreateUnchecked` in crate `prisma_client_rust`
   --> src/db.rs:646:63
    |
646 |     pub type CreateUncheckedQuery<'a> = ::prisma_client_rust::CreateUnchecked<'a, Types>;
    |                                                               ^^^^^^^^^^^^^^^ not found in `prisma_client_rust`

error[E0412]: cannot find type `UpdateUnchecked` in crate `prisma_client_rust`
   --> src/db.rs:652:63
    |
652 |     pub type UpdateUncheckedQuery<'a> = ::prisma_client_rust::UpdateUnchecked<'a, Types>;
    |                                                               ^^^^^^^^^^^^^^^ not found in `prisma_client_rust`

warning: unused import: `tauri_specta::ts`
  --> src/main.rs:26:5
   |
26 | use tauri_specta::ts;
   |     ^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused variable: `db`
  --> src/main.rs:57:5
   |
57 |     db: DbState<'_>,
   |     ^^ help: if this is intentional, prefix it with an underscore: `_db`
   |
   = note: `#[warn(unused_variables)]` on by default

error[E0277]: the trait bound `SetParam: From<UncheckedSetParam>` is not satisfied
   --> src/db.rs:607:29
    |
607 |         type UncheckedSet = UncheckedSetParam;
    |                             ^^^^^^^^^^^^^^^^^ the trait `From<UncheckedSetParam>` is not implemented for `SetParam`
    |
    = help: the following other types implement trait `From<T>`:
              <SetParam as From<content::Set>>
              <SetParam as From<content::UpdateOperation>>
Raduc4 commented 10 months ago

After playing with dependencies I could run the app using Prisma client and even insert something random in the SQLite DB. However, cargo prisma generate seems to not work properly. The generator misses a : when generating the db.rs file, requiring to add it manually. A reproduction of this can be seen here.

Delete db.rs cd src-tauri cargo prisma generate the error is on line 641 Citadel Workspace

Brendonovich commented 10 months ago

You haven't set a tag for the prisma-client-rust-cli dependency, it needs to match the tag used for prisma-client-rust.

Raduc4 commented 10 months ago

Thanks for the hint. tag="0.6.9" made the app to compile, however the db.rs file still has errors. Is this a normal behavior?

Brendonovich commented 10 months ago

It's normal to have warnings, which can be silenced. If there's errors please open another issue.

Raduc4 commented 10 months ago

In the end, that was a rust-analyzer freeze. All is good, thanks