Closed fdarian closed 8 months ago
While messing around with the lib last night I noticed a bug that Im not sure would be solved by this.
When a model references itself as a relation like....
model Post {
subPosts Post[]
}
It seems like the generated file tries to import itself for the relation.
While messing around with the lib last night I noticed a bug that Im not sure would be solved by this.
When a model references itself as a relation like....
model Post { subPosts Post[] }
It seems like the generated file tries to import itself for the relation.
Sorry, I've just had the chance to check, I just added the test for self-reference and it works just fine, also I think this PR isn't related to the problem. Could you please provide a reproductive case where it fails?
In the cases of my schema where I notice the issue is definitely in the few places where a model has a self referencing relation. So if those relations are now broken out into their own files, I would expect that to be working properly.
In the cases of my schema where I notice the issue is definitely in the few places where a model has a self referencing relation. So if those relations are now broken out into their own files, I would expect that to be working properly.
So this is the test schema that I added
model SelfReference {
id String @id
referringManyId String?
referringMany SelfReference? @relation("SelfReference_referringMany", fields: [referringManyId], references: [id])
referredMany SelfReference[] @relation("SelfReference_referringMany")
referringUniqueId String? @unique
referringUnique SelfReference? @relation("SelfReference_referringUnique", fields: [referringUniqueId], references: [id])
referredUnique SelfReference? @relation("SelfReference_referringUnique")
}
As well as the test: https://github.com/farreldarian/prisma-generator-drizzle/blob/pgd-11-circular-dependency-on-generated-schema/packages/usage/tests/shared/testSelfReferring.ts
All is working as expected, do you encounter a specific error that I could look at? you could try by installing the 0.5.4-9955142 version
Hey, sorry for the delay I'll take a look at if the new version solves what I was seeing.
@farreldarian I just ran a quick test with the separated relations with the 0.5.4 version you gave me and the issue I was seeing is now gone
Quick test with the separated relations with the 0.5.4 version you gave me and the issue I was seeing is now gone
Awesome! I'm just gonna merge this now, if anything comes up please feel free to raise a new issue
Resolves #11