laravel-json-api
laravel-json-api copied to clipboard
Use select('resource_table.*') on query by default
Hello guys!
In my API I do need to make some joins in the query to apply my filter logic. However if my joining table has the same field name of my resource table (main table) the joiner table's field replaces the one of main table. This is a Laravel/Eloquent problem, but forces me to add a $query->select('resource_table.*') at least the first time I make a join.
In your demo application you already makes use of resource_table. syntax when adding where to the query, because the same problem would happen.
So my question is: May we have this piece of code directly added to AbstractAdapter?
Actually you do not have in your code any select() function to the query even if sparse fields is given. I got that this is done by neomerx/json-api Encoder and ResourceObject through your default Encoder - that extends neomerx's one - and our resource Schema.
Thanks!
Yes think there might be a case for doing something around select, particularly when sparse fieldsets are requested. I'm not sure I can prioritise this at the moment though as there's more than enough other stuff to sort out - but will leave this open so that we can add it in a future version.