mirror of
https://github.com/ash-project/ash.git
synced 2024-09-19 13:03:02 +12:00
fix: don't select destination attributes that don't exist
This commit is contained in:
parent
b97040c9c4
commit
be807aa9e2
2 changed files with 8 additions and 7 deletions
|
@ -599,11 +599,12 @@ defmodule Ash.Actions.Read.Relationships do
|
|||
end
|
||||
|
||||
defp select_destination_attribute(related_query, relationship) do
|
||||
if Map.get(relationship, :manual) &&
|
||||
!Ash.Resource.Info.attribute(
|
||||
relationship.destination,
|
||||
relationship.destination_attribute
|
||||
) do
|
||||
if Map.get(relationship, :no_attributes?) ||
|
||||
(Map.get(relationship, :manual) &&
|
||||
!Ash.Resource.Info.attribute(
|
||||
relationship.destination,
|
||||
relationship.destination_attribute
|
||||
)) do
|
||||
related_query
|
||||
else
|
||||
Ash.Query.ensure_selected(related_query, [relationship.destination_attribute])
|
||||
|
|
|
@ -194,7 +194,7 @@ defmodule Ash.Test.Resource.ResourceTest do
|
|||
attributes do
|
||||
uuid_primary_key :id
|
||||
attribute :name, :string, public?: true
|
||||
attribute :current_year, :integer, public?: :true
|
||||
attribute :current_year, :integer, public?: true
|
||||
end
|
||||
|
||||
relationships do
|
||||
|
@ -220,7 +220,7 @@ defmodule Ash.Test.Resource.ResourceTest do
|
|||
delorean = Ash.load!(delorean, [:next_machine])
|
||||
assert delorean.next_machine.name == "San Dimas Phone Booth"
|
||||
|
||||
delorean = Ash.load!(delorean, [next_machine: [:name]])
|
||||
delorean = Ash.load!(delorean, next_machine: [:name])
|
||||
assert delorean.next_machine.name == "San Dimas Phone Booth"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue