Using relation columns in where clause (Drizzle playground provided)
I have a one-to-one relationship with a schema defined like: https://drizzle.run/uwkkt8l10cgp5okr1r41tjfu
When I run that query, I get the following error
column agent.deleted does not exist
. Why can't you reference relation columns in a top-level where clause? Is there a better way to do this without using the select
API with joins?Drizzle Run
undefined - Drizzle Run
7 Replies
I can't open that playgroud. can you make sure you clicked "share"?
sorry about that, i did not. it's shared now: https://drizzle.run/uwkkt8l10cgp5okr1r41tjfu
Drizzle Run
New blank playground - Drizzle Run
This is what you'd do
Use a subquery
I just added some seed statements
Got it, thanks for the response! So I guess there isn't any way to query on relations in a single query using the Query API? Your solution works and it provides the data in the structure I was hoping for, but it also requires two trips to the DB 🫤
Do you think this is an intentional design decision or potentially just a missed feature?
It does not require two trips to the database, you can delete the first request and is still going to work
The subquery is not a request, I wrote it that way for readability