cross_join on a Ash.Query
Hi
I am able to do a cross_join on a Ecto.Query style.
I am not able to convert to the Ecto.Query -> Ash.Query
o r I am not able to perfrom Ecto.Query.from style cross_join on the Ash.Query in the prepare fn.
Please advise.
6 Replies
can you show me an example of what you're trying to do?
Hi Zach,
Here is the example. I could not figure out how to convert this to ash query or use query in the first place.
So, in SQL a cross join can produce duplicates in your query
Generally speaking this is not something that makes sense in the resource-oriented world
However, you may be able to use the
modify_query
option
If you could lay out the specific use case (like what kind of result you want to produce from your action, I might be able to advise more.Basic idea was to generate the time slots which are not reserved
There are reservations which are made, now trying to find the timeslots which are not allocated
So what I think you would do here is make a calculation
Although I assume you need to filter on this in some way?
Another option would be to create a view.
Actually a view doesn't quite work in your instance either
I think I might do it this way:
This is a bit different, in that its a subquery per row and not a cross join. That may mean that it won't perform as well, you'll have to try it out
Thanks Zach I will try it out.