Brendonovich / prisma-client-rust

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

Unique constraints with composite type fields #448

Open darkyeg opened 6 months ago

darkyeg commented 6 months ago

user and phone model

model User {

  phone          PhoneNumber?

  @@unique(name: "unqiue_phone", [phone.countryCode, phone.number])
}

type PhoneNumber {
  countryCode String
  number      String
}

the generated


    pub fn phone_phone<T: From<UniqueWhereParam>>(
        phone: crate::prisma::phone_number::Data,
        phone: crate::prisma::phone_number::Data,
    ) -> T {
        UniqueWhereParam::PhonePhoneEquals(phone, phone).into()
    }
Brendonovich commented 6 months ago

TIL that's valid Prisma syntax. Could you make a reproduction of this? Would help with implementing it.

darkyeg commented 6 months ago

TIL that's valid Prisma syntax. Could you make a reproduction of this? Would help with implementing it.

No problems, there are other problems related to composite type, I will try to add them all in a repository.

darkyeg commented 6 months ago

@Brendonovich I have gathered all the issues encountered with composite types in one repository. If I encounter any other issues, I will add them to the same location and inform you. Each problem has been placed in a separate branch. https://github.com/darkyeg/prisma-rust-composite-problems