No type inference when specifying a reference.
Hi, I am trying out Drizzle for my application, and I am having some issues when I have a table that has a one-to-one and one-to-many relation on another table. I have the following schema:
Which generates the following SQL:
3 Replies
This is all fine, until I want to add a reference from
primary_guest_id
to the guest id
. If I change the following line:
to:
Now suddenly the ORM is no longer able to infer a TypeScript type (both invitations
and guests
are any
, and I get the following errors:
It seems however that Drizzle kit is able to create the SQL:
Why are my TypeScript types getting borked? How can this be fixed?
I have a feeling this is a circular reference issue, as when I remove the .references(() => invitations.id),
from invitationId
this all seems to work.Logged an issue for this: https://github.com/drizzle-team/drizzle-orm/issues/2476
GitHub
[BUG]: Circular reference causes type to become
any
· Issue #2476...What version of drizzle-orm are you using? 0.31.2 What version of drizzle-kit are you using? 0.22.6 Describe the Bug When two tables reference each other in a circular manner the types of the table...
Hmmm, upon closer inspection I need a seperate table to link both together, so perhaps what I am doing here is invalid.