Disambiguate optional one-to-one relationship

This is a similar problem to https://discord.com/channels/1043890932593987624/1084576896039260202/threads/1254869164607143998 - but instead involves two tables, one of which has a non-nullable foreign key to the other. https://drizzle.run/my887gq5kvpp1ogl3xpoe0zh I have table A that has an id column, and table B that has a nullable reference to table A on a unique column. This is an optional one-to-one relationship, however, there is another column on table B that is not unique and should have a many-to-one relationship to table A. It's possible to disambiguate many-to-one relationships, but I'm not sure how to disambiguate a one-to-one without including fields and references on the ambiguous one() on table A which makes the one-to-one relationship incorrectly non-nullable.
8 Replies
francis
francisOP2w ago
bump? any thoughts? bump? :/ I can't figure out how to do this ?
Mario564
Mario5642w ago
@francis The playground link doesn't work
francis
francisOP2w ago
ah, thank you - fixed
Mario564
Mario5642w ago
@francis Would deleting the relationName property from user_userId work? That way, I assume the unnamed relations will work. Don't have a way to test it in the playground
francis
francisOP2w ago
I am pretty sure that won't, as it is now an ambiguous relation, no?
Mario564
Mario5642w ago
I think it's not possible to pass a relation name without specifying fields and references, so this would be a workaround. The reason why I think it would work is that it's the only unnamed relation, so the two sides should be "linked" because in both sides, the relations are unnamed
I think it's not possible to pass a relation name without specifying fields and references, so this would be a workaround
This is an oversight in the RQB API, we should definitely aim to fix this
francis
francisOP2w ago
GitHub
[BUG]: Allow specifying relationName for one-to-one relationships o...
Report hasn't been filed before. I have verified that the bug I'm about to report hasn't been filed before. What version of drizzle-orm are you using? 0.36.4 What version of drizzle-kit...
Want results from more Discord servers?
Add your server