Many-to-Many where in far table
I'm trying to
findMany()
Pokemon(s) by a type name
querying like this...
If the where
def. is on the far relation, the result-set is returning item(s) like this:
It returned totally wrong records from pokemons
and the pivot table. No of the returned typeUuid
s are of type
.name
= 'Water'
).
Any ideas where I could go wrong? Are where
expressions in relational M:N tables supported?6 Replies
did you figure out what was wrong? Just hit the same wall ish.
What you’re filtering here is the type itself. That is “when retrieving the type, include it if this is true, otherwise return null”, rather than conditionally including pokemonToType. Unfortunately the relational query builder doesn’t support filtering a table on a related table currently - it’s planned, but for now you’d need to use the core query builder
So docs is incorrect then, or is it only supported for one-to-many?
https://orm.drizzle.team/docs/rqb#select-filters
The docs are correct. In the example it gives there, it returns the post with id=1 and the subset of comments before some date, NOT the post id=1 IF it has some comments before some date
So how would i do this using the query builder?
Something like this?:
Looks reasonable on a quick glance