Skip to content

Commit

Permalink
fix: properly merge query calculations when one side is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Oct 1, 2024
1 parent 2f086f4 commit c553c5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ash/query/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ defmodule Ash.Query do
def load(query, load_statement, opts \\ [])

def load(query, %Ash.Query{} = new, _opts) do
merge_load(query, new)
query |> new() |> merge_load(new)
end

def load(query, fields, opts) when not is_list(fields) do
Expand Down Expand Up @@ -3125,6 +3125,8 @@ defmodule Ash.Query do
end)
end

defp merge_load([], %Ash.Query{} = right), do: right
defp merge_load(%Ash.Query{} = left, []), do: left
defp merge_load([], right), do: sanitize_loads(right)
defp merge_load(left, []), do: sanitize_loads(left)

Expand Down
1 change: 1 addition & 0 deletions lib/ash/type/struct.ex
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ defmodule Ash.Type.Struct do
instance_of = constraints[:instance_of]

if instance_of do
# instance_of_query = Ash.Query.new(instance_of)
left = Ash.Query.load(instance_of, left)
right = Ash.Query.load(instance_of, right)

Expand Down

0 comments on commit c553c5b

Please sign in to comment.