mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: only apply load through for attributes that are being selected directly
fix: ensure we lateral join with `from_many?: true` or any `:many` cardinality relationships
This commit is contained in:
parent
8dc0c2cb05
commit
5d4c51015e
2 changed files with 3 additions and 3 deletions
|
@ -432,7 +432,6 @@ defmodule Ash.Actions.Read do
|
||||||
),
|
),
|
||||||
query <- Map.put(query, :filter, filter),
|
query <- Map.put(query, :filter, filter),
|
||||||
query <- Ash.Query.unset(query, :calculations),
|
query <- Ash.Query.unset(query, :calculations),
|
||||||
query <- add_relationship_count_aggregates(query),
|
|
||||||
{%{valid?: true} = query, before_notifications} <- run_before_action(query),
|
{%{valid?: true} = query, before_notifications} <- run_before_action(query),
|
||||||
{:ok, count} <-
|
{:ok, count} <-
|
||||||
fetch_count(
|
fetch_count(
|
||||||
|
@ -1192,7 +1191,7 @@ defmodule Ash.Actions.Read do
|
||||||
query.resource
|
query.resource
|
||||||
|> Ash.Resource.Info.attributes()
|
|> Ash.Resource.Info.attributes()
|
||||||
|> Enum.filter(fn %{name: name, type: type, constraints: constraints} ->
|
|> Enum.filter(fn %{name: name, type: type, constraints: constraints} ->
|
||||||
Ash.Type.can_load?(type, constraints) && Ash.Query.selecting?(query, name)
|
Ash.Type.can_load?(type, constraints) && (is_nil(query.select) || name in select)
|
||||||
end)
|
end)
|
||||||
|> Enum.map(& &1.name)
|
|> Enum.map(& &1.name)
|
||||||
|> Enum.reduce(query.load_through, fn name, load_through ->
|
|> Enum.reduce(query.load_through, fn name, load_through ->
|
||||||
|
|
|
@ -921,7 +921,8 @@ defmodule Ash.Actions.Read.Relationships do
|
||||||
false
|
false
|
||||||
|
|
||||||
limit == 1 && is_nil(relationship.context) && is_nil(relationship.filter) &&
|
limit == 1 && is_nil(relationship.context) && is_nil(relationship.filter) &&
|
||||||
is_nil(relationship.sort) && relationship.type != :many_to_many ->
|
is_nil(relationship.sort) && relationship.cardinality != :many &&
|
||||||
|
!Map.get(relationship, :from_many?) ->
|
||||||
has_parent_expr?(relationship)
|
has_parent_expr?(relationship)
|
||||||
|
|
||||||
limit == 1 && (source_data == :unknown || Enum.count_until(source_data, 2) == 1) &&
|
limit == 1 && (source_data == :unknown || Enum.count_until(source_data, 2) == 1) &&
|
||||||
|
|
Loading…
Reference in a new issue