Self join breaks return type
Same issue as https://discord.com/channels/1043890932593987624/1286374226667896914
The return type of the query is
never[]
. If I remove the left join, things return to normal.
The query works as expected, the result is just never[]
.
6 Replies
May be worth mentioning that doing the same query within the query API returns the expected type:

I've created a full example, hopefully I'm just missing something
https://drizzle.run/vgpyb731hdqu7u73og9crp63
Drizzle Run
self join - Drizzle Run
Hey there. Fixed by by using
alias
function instead of aliasedTable
@SpoderManInteresting. Thank you!
What's the TLDR of the difference between the 2?
Don't know honestly. I think
aliasedTable
is an outdated implementation of alias
. The former is likely to be deprecated and then removed in v1Awesome, thanks a ton.
For anyone else who was using this the same way I was, I have a tip.
I was taking the result of
aliasedTable
and passing it through to a function using a function signature like this:
function withChildren<T extends users>(parent: T)
alias
returns a slightly different type. There might be a better way to get that type, but this appears to be working
type UserAlias = ReturnType<typeof alias<typeof users, "parent">>;
Then I changed the function signature to
function withChildren<T extends UserAlias>(parent: T)