-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with Identifier Types and Composite Foreign Keys (kanel + kysely) #571
Comments
Hmm, yes, I see the problem but I admit that I am not sure where in the chain the bug lies. |
Sounds great. Except for me managing to stub my toes here kanel has been excellent to me. I'll try the post render hook first just to bandaid the situation. If you have any examples handy (that aren't already in this repo) that would be helpful, but if not no worries! I'll also keep you posted if I am able to debug or chase the issue down myself. |
Something I just noticed because I bumped to
(Upon further inspection the So this is a clue at least, I can't spend much more time today digging in but I'll report back when I get the chance to spend more time on it. It appears the issue stems from a parent FKEY referencing columns in a child who are themselves also an FKEY. I'm still unsure if the composite FKEY aspect comes into play. |
TLDR Found possibly an edge case, possibly an issue on my end, involving composite foreign keys and would love guidance on next steps (fix my kanel configs? learn where in kanel this could be happening an help contribute a fix? wait for a fix?)
I have recently come across an issue where Kanel (+ Kanel-Kysely) generates problematic outputs as my schema has evolved to have more complex compound foreign keys. It's possible my configurations are bad or I'm doing something very silly.
Important
I have created a code sandbox MVP reproduction to illustrate what happens. This sandbox has my exact
.kanelrc.js
along with the schema below.The TLDR of the issue is when I have a moderately complex n:m type join table in situations where both sides of the join have composite primary keys. Kanel attempts to do an
OR
union of the "identifier" types (but for only one side of the equation) for identifier types it... doesn't actually create.Given the following postgres schema:
And a
.kanelrc.js
almost entirely based on https://github.com/kristiandupont/kanel/blob/main/example/.kanelrc.js, we get the following outputs.Note
Specifically notice how
ABMatch.ts
is attempting to importBOrganizationId
fromB.ts
and union it withOrganizationId
, howeverB.ts
doesn't actually define or exportBOrganizationId
In an ideal world, Kanel would not attempt to create
BOrganizationId
nor would it attempt to union it withOrganizationId
.ABMatch.ts
B.ts
The text was updated successfully, but these errors were encountered: