Hello. I’m totally stuck and confused what I’m doi...
# prisma-client
a
Hello. I’m totally stuck and confused what I’m doing wrong, maybe you, guys, can help. I’m trying to create record with:
Copy code
prisma.role.create({
    data: {
        Id: 1,
        Name: 'Test',
        Description: 'Test',
        IsActive: true,
        CreatedByUser: { connect: { Id: 2 } },
        LastUpdateByUser: { connect: { Id: 2 } },
    },
});
and PrismaClient doesn’t allow me to, because of:
Copy code
Types of property 'Id' are incompatible. Type 'number' is not assignable to type 'never'.`
and hinting me about:
Copy code
The expected type comes from property 'data' which is declared here on type '{ select?: RoleSelect; include?: RoleInclude; data: (Without<RoleCreateInput, RoleUncheckedCreateInput> & RoleUncheckedCreateInput) | (Without<...> & RoleCreateInput); }'
and my question is - why PrismaClient doesn’t allow me to use Id for creating? in my model schema I have simply:
Copy code
Id                    Int      @id @default(autoincrement())
Similar result I have with upsert as well. And what is totally weird to me - some models works fine. I already spend 2 hours to figure out why it happens to this particular model. Can anyone help?
a
Hey @Adam, we are glad to have you in our community! I was unable to reproduce this issue, could you share your
schema.prisma
file?
a
Thank yo @Austin for your reply and warm welcome, I’m glad to be here 🙂 There is one important thing I didn’t mention before - the problem occurs only while seeding the data. I have
prisma/seed.ts
file and run
prisma db seed
with:
Copy code
"prisma": {
  "seed": "ts-node prisma/seed.ts"
}
in package.json. My schema.prisma has around 1.5k lines and I can’t share it all, but I hope it would be anyhow helpful.
Copy code
datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

generator client {
  provider        = "prisma-client-js"
}

model Role {
  Id                    Int      @id @default(autoincrement())
  Name                  String   @db.VarChar(300)
  Description           String?  @db.VarChar(2000)
  IsActive              Boolean
  DefaultForProjectRole Int?
  CreatedByUserId       Int
  CreatedDateTime       DateTime @default(now())
  LastUpdateByUserId    Int
  LastUpdateDateTime    DateTime @updatedAt

  DefaultForProjectRoleRelation ProjectRole? @relation(fields: [DefaultForProjectRole], references: [Id])
  CreatedByUser                 TaskerUser   @relation(fields: [CreatedByUserId], references: [Id], name: "RoleCreatedByUser")
  LastUpdateByUser              TaskerUser   @relation(fields: [LastUpdateByUserId], references: [Id], name: "RoleLastUpdateByUser")

  TaskerUserRole             TaskerUserRole[]
  PermissionToRole           PermissionToRole[]           @relation("PermisionToRoleRole")
  ProjectRoleToProjectToRole ProjectRoleToProjectToRole[]
  @@map(name: "role")
}
I use
3.2.1
version of
prisma
and
@prisma/client
.
a
Could you update to the latest version (3.30) and try again? If that doesn't work, please create a bug report (ideally with a minimal reproduction repo) and our engineering teams will take a look 👍 .
👍 1