You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Database Adapter and Versions (postgrex, myxql, etc)
all
Current behavior
Currently you can use struct/2 to retrieve only certain fields from the underlying table and still have the result return as the struct you want and still have preloads.
My coworker had a situation where they also wanted to restrict the attributes coming from an embedded field within the table. The best I was able to suggest was to use select_merge, like this:
There may be a more standard way to do this that I am not thinking of. But assuming the way above is the best way to do it currently, would it make sense to allow something like this
One thing I realized is it would probably be helpful to have a way to extract subsets of json for this behaviour. I think it can get a bit tricky to select each path individually and then try to rebuild the potentially nested object at the end.
The way this is done in Postgres/MySQL is to use functions like this:
Or I guess the API I suggested makes more sense with the name json_subset. And if we want to add json_object we keep the alternating key/value arguments.
Elixir version
all
Database and Version
all
Ecto Versions
3.12
Database Adapter and Versions (postgrex, myxql, etc)
all
Current behavior
Currently you can use
struct/2
to retrieve only certain fields from the underlying table and still have the result return as the struct you want and still have preloads.My coworker had a situation where they also wanted to restrict the attributes coming from an embedded field within the table. The best I was able to suggest was to use
select_merge
, like this:There may be a more standard way to do this that I am not thinking of. But assuming the way above is the best way to do it currently, would it make sense to allow something like this
Expected behavior
TBD
The text was updated successfully, but these errors were encountered: