Brendonovich / prisma-client-rust

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

Enum list can't call to_string on Vec #303

Closed asaadmohammed74 closed 1 year ago

asaadmohammed74 commented 1 year ago

using arrays of enum in the schema causes a vec to be generated

model RebelCollect {
    id             Int          @id @default(autoincrement())
    hero_ids       HeroId[]
}
pub struct Data {
        #[serde(rename = "id")]
        pub id: i32,
        #[serde(rename = "hero_ids")]
        pub hero_ids: Vec<super::HeroId>,
}

then in the WhereInput serialization it tries to call to_string on a Vec<HeroId>

      Self::RebelsConfigIdHeroIdsEquals(rebels_config_id, hero_ids) => (
                    "rebelsConfigId_hero_ids",
                    ::prisma_client_rust::SerializedWhereValue::Object(vec![
                        (
                            rebels_config_id::NAME.to_string(),
                            ::prisma_client_rust::PrismaValue::Int(rebels_config_id as i64),
                        ),
                        (
                            hero_ids::NAME.to_string(),
                            ::prisma_client_rust::PrismaValue::Enum(hero_ids.to_string()), // this line
                        ),
                    ]),
                ),
`std::vec::Vec<prisma::HeroId>` cannot be formatted with the default formatter

400   | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
      | ------------------------------------------------------------------------------------------------
      | |
      | doesn't satisfy `std::vec::Vec<prisma::HeroId>: ToString`
      | doesn't satisfy `std::vec::Vec<prisma::HeroId>: std::fmt::Display`
      |
      = note: the following trait bounds were not satisfied:
              `std::vec::Vec<prisma::HeroId>: std::fmt::Display`
              which is required by `std::vec::Vec<prisma::HeroId>: ToString`
              `[prisma::HeroId]: std::fmt::Display`
              which is required by `[prisma::HeroId]: ToString`
Brendonovich commented 1 year ago

Classic enum mistake, my bad.