-
My setup is pretty simple. I have 4 tables and they're related only 2 layers deep, but I want a query that goes deeper. Here's what I mean:
By the names you can figure out the relations, primary keys are set on all overlapping ids. If I start the query from posts it all works perfectly. Now things get deeper when I'm starting from categories (without playlist) as it's a 2-level deep join:
And here's where I'm stuck, when going to the third level adding playlistitems I get an error.
My error points at missing primary keys, but I've double checked and it's not the case, so this is either simply not possible or a bug? Can someone clear that up for me please?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Solved. Going to leave this here in case someone else faces the same issue.
Thanks to Copilot for this one, couldn't answer it even after questioning it a hundred times, but suggested it on another query. |
Beta Was this translation helpful? Give feedback.
Solved. Going to leave this here in case someone else faces the same issue.
The "trick" is to embrace the deeper level dependency in brackets of its parent, like so:
.from('category').select('name, posts(title, playlistitems(id)) postmeta('id)
Thanks to Copilot for this one, couldn't answer it even after questioning it a hundred times, but suggested it on another query.