How to create a Union query within different resources with Combination

Looks like the api to perform a Union query is https://hexdocs.pm/ash/combination-queries.html but what would be the best way to create a union query between different resources?
5 Replies
ZachDaniel
ZachDaniel4mo ago
At the moment a generic action is the only thing that can return a union As an action
Marco Dell'Olio
Marco Dell'OlioOP4mo ago
that's fine, but how can I run a union query from two different resources?
ZachDaniel
ZachDaniel4mo ago
oh, sorry, you mean using combination queries you cannot currently You would need to use ecto in some fashion, or create a postgres view for example
Marco Dell'Olio
Marco Dell'OlioOP4mo ago
what about a sql fragment? I don't really want to upkeep with a mirror ecto schema
ZachDaniel
ZachDaniel4mo ago
All Ash.Resource modules are also Ecto.Schema modules
query =
from row in Your.Resource,
select: row

Repo.all(query)
query =
from row in Your.Resource,
select: row

Repo.all(query)
works There are some limitations (assoc doesn't work)

Did you find this page helpful?