fix: support embeds in relationships

This commit is contained in:
Zach Daniel 2021-04-27 14:18:48 -04:00
parent 6b2d3c5f9b
commit 5c3ea08838

View file

@ -593,10 +593,13 @@ defmodule AshPhoenix do
"""
def add_embed(query, path, outer_form_name, add \\ %{})
def add_embed(%Ash.Changeset{} = changeset, path, outer_form_name, add) do
[^outer_form_name, key | path] = decode_path(path)
def add_embed(%Ash.Changeset{} = changeset, original_path, outer_form_name, add) do
[^outer_form_name, key | path] = decode_path(original_path)
cond do
match?({x, y} when not is_nil(x) and not is_nil(y), argument_and_manages(changeset, key)) ->
add_related(changeset, original_path, outer_form_name, add: add)
attr = Ash.Resource.Info.attribute(changeset.resource, key) ->
current_value = Ash.Changeset.get_attribute(changeset, attr.name)