zod-prisma-types
zod-prisma-types copied to clipboard
Error updating prisma and zod-prisma-types
Recently updated @prisma/client
and prisma
from versions 4.10.1
to 4.15.0.
I also updated zod-prisma-types
from 2.5.4
to 2.7.3
. I have also ensured that we are using zod
version 3.21.1
(since I know there is a known issue with higher versions)
Since then, generating zod types seems to work but when trying to build my application I get the following error:
prisma/generated/zod/index.ts(6347,14): error TS2451: Cannot redeclare block-scoped variable 'ProductListRelationFilterSchema'.
prisma/generated/zod/index.ts(6610,14): error TS2322: Type 'ZodObject<{ every: ZodOptional<ZodLazy<ZodType<ProductWhereInput, ZodTypeDef, ProductWhereInput>>>; some: ZodOptional<...>; none: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>' is not assignable to type 'ZodType<ProductListRelationFilter, ZodTypeDef, ProductListRelationFilter>'.
Types of property '_type' are incompatible.
Type '{ every?: ProductWhereInput | undefined; some?: ProductWhereInput | undefined; none?: ProductWhereInput | undefined; }' has no properties in common with type 'ProductListRelationFilter'.
prisma/generated/zod/index.ts(6610,14): error TS2451: Cannot redeclare block-scoped variable 'ProductListRelationFilterSchema'.
Could someone gives us the latest tested package versions for @prisma/client, prisma, zod-prisma-types and zod?
@gascenciom1998 @odysseaspapadimas I'll look into it. the generator currently uses @prisma/internals": "^4.13.0
and @prisma/generator-helper": "^4.13.0
. I'll update to the latest versions and see if I can reproduce the error
in the latest version I updated the relevant prisma packages to 4.15
, tested it with my schema and was able to compile it. Can you please test your setup with the latest version and see if the bug disappears? If not, can you please provide me with a prisma schema
where the bug occures?
@chrishoermann This schema.prisma
results in the error from my original post, using latest versions of zod-prisma-types
, prisma
, and @prisma/client
:
generator jsclient {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
binaryTargets = ["native", "rhel-openssl-1.0.x"]
}
generator zod {
provider = "zod-prisma-types"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model ProductList {
id String @id @default(uuid())
products RefProductList[]
}
model RefProductList {
productId String
listId String
list ProductList @relation(fields: [listId], references: [id])
product Product @relation(fields: [productId], references: [id])
@@id([productId, listId])
}
model Product {
// PK and FK
id String @id @default(uuid())
categoryId String
// relations
category Category @relation(fields: [categoryId], references: [id])
lists RefProductList[]
}
model Category {
id String @id @default(uuid())
products Product[]
}
Bumping - we're having the same issue when upgrading Prisma from 4.10.x to any higher version.
Any update on this? I am also getting a error on next build. The generate is fine but there is a type error of string
is not assigned to undefined and not sure why it is saying this.
Bumping again, still no luck with upgrading. Stuck on Prisma 4.10.x which is now causing us other problems.
Any update on this? I am also getting a error on next build. The generate is fine but there is a type error of
string
is not assigned to undefined and not sure why it is saying this.
I am getting the same issue.
Bump on this, also experiencing the same issue
@gascenciom1998 I did some digging and in your case this seems to actually be a model naming issue. I think that List
in a model name can somehow lead to conflicts because prisma generates types , where List
is appended to the model name, whenever this model is somewhere used as a list relation
.
in your provided schema prisma generates two types with the name ProductListRelationFilter
. One comes from the list relation in the Category
model and the other from the relation to ProductList
in the RefProductList
model. The generator only replicates these types as schemas.
When you change the name of the ProductList
model to e.g. ProductCollection
the error goes away since there are no more naming collisions between types.
So please check for any model names that include List
since it seems that this is a somewhat reserved name in prisma
.
Please report back if you still encounter this issue.
Wow this seems to have worked thanks so much @chrishoermann