mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 05:23:03 +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 <- Ash.Query.unset(query, :calculations),
|
||||
query <- add_relationship_count_aggregates(query),
|
||||
{%{valid?: true} = query, before_notifications} <- run_before_action(query),
|
||||
{:ok, count} <-
|
||||
fetch_count(
|
||||
|
@ -1192,7 +1191,7 @@ defmodule Ash.Actions.Read do
|
|||
query.resource
|
||||
|> Ash.Resource.Info.attributes()
|
||||
|> 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)
|
||||
|> Enum.map(& &1.name)
|
||||
|> Enum.reduce(query.load_through, fn name, load_through ->
|
||||
|
|
|
@ -921,7 +921,8 @@ defmodule Ash.Actions.Read.Relationships do
|
|||
false
|
||||
|
||||
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)
|
||||
|
||||
limit == 1 && (source_data == :unknown || Enum.count_until(source_data, 2) == 1) &&
|
||||
|
|
Loading…
Reference in a new issue