Hey guys, I am wondering if you also experienced t...
# orm-help
j
Hey guys, I am wondering if you also experienced this issue. When calling a nested create and some of the keys end with
Id
even tho it’s not meant to be a foreign key, the mutation errors. Example:
Copy code
prisma.business.create({
    data: {
      name: data.name,
      // This is just a string and it is not supposed to be a FK, but Prisma thinks so
      taxId: data.taxIdentifier,
      address: {
        create: {...},
      },
      clientOf: {
        connect: {
          id: businessId,
        },
      },
    },
  })
The way to fix this is to rename it from
taxId
to
taxIdentifier
for example. I was trying to find an issue in Github, but there is just so many issues and it’s hard to find it.
r
@Jaroslav Malek 👋 That’s strange, which version of Prisma are you on? I would like to reproduce this.
j
HI @Ryan 3.1.1
r
Alright, could you share that part of your schema?
j
@Ryan here it is:
Copy code
model Business {
  id        String   @id @default(cuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt


  isClient Boolean @default(true)

  domain        String?
  taxIdentifier String?
  vatIdentifier String?
  name          String

  addressId String?
  address   Address? @relation(fields: [addressId], references: [id])

 
  clients Business[] @relation("BusinessToBusiness")

  clientOf   Business? @relation("BusinessToBusiness", fields: [clientOfId], references: [id])
  clientOfId String?
}

model Address {
  id        String   @id @default(cuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  countryCode String
  city        String?
  line1       String?
  line2       String?
  zip         String?
  isPrimary   Boolean @default(false)

  businesses Business[]
}
r
Works fine for me with
taxId
as well. I think the issue is different here.
Here’s an example:
Prisma only checks the foreign key and not the name. I’m pretty sure you’re passing a value as
undefined
in the
data
j
This is very weird, the test works for me as well. I’ll come back to you if I hit the issue again. Thank you!
👍 1
💯 1