mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: properly determine reverse aggregate relationship
fix: ensure calculation modules are compiled
This commit is contained in:
parent
382d39175b
commit
5f05f683c2
2 changed files with 12 additions and 1 deletions
|
@ -34,6 +34,7 @@ defmodule Ash.Actions.Sort do
|
|||
|
||||
calc ->
|
||||
{module, opts} = calc.calculation
|
||||
Code.ensure_compiled(module)
|
||||
|
||||
if :erlang.function_exported(module, :expression, 2) do
|
||||
if Ash.DataLayer.data_layer_can?(resource, :expression_calculation_sort) do
|
||||
|
|
|
@ -141,8 +141,18 @@ defmodule Ash.Query.Aggregate do
|
|||
List.first(relationship_path)
|
||||
)
|
||||
|
||||
path_for_checking =
|
||||
relationship_path
|
||||
|> tl()
|
||||
|> Enum.reduce({[], aggregate_resource}, fn rel, {path, resource} ->
|
||||
relationship = Ash.Resource.Info.relationship(resource, rel)
|
||||
{[relationship | path], relationship.destination}
|
||||
end)
|
||||
|> elem(0)
|
||||
|> Enum.reverse()
|
||||
|
||||
{in_query?, reverse_relationship} =
|
||||
case Load.reverse_relationship_path(relationship, tl(relationship_path)) do
|
||||
case Load.reverse_relationship_path(relationship, path_for_checking) do
|
||||
:error ->
|
||||
{ref_path == [] && can_be_in_query?, nil}
|
||||
|
||||
|
|
Loading…
Reference in a new issue