mirror of
https://github.com/ash-project/ash_phoenix.git
synced 2024-09-20 07:12:49 +12:00
fix: support embeds in relationships
This commit is contained in:
parent
6b2d3c5f9b
commit
5c3ea08838
1 changed files with 5 additions and 2 deletions
|
@ -593,10 +593,13 @@ defmodule AshPhoenix do
|
||||||
"""
|
"""
|
||||||
def add_embed(query, path, outer_form_name, add \\ %{})
|
def add_embed(query, path, outer_form_name, add \\ %{})
|
||||||
|
|
||||||
def add_embed(%Ash.Changeset{} = changeset, path, outer_form_name, add) do
|
def add_embed(%Ash.Changeset{} = changeset, original_path, outer_form_name, add) do
|
||||||
[^outer_form_name, key | path] = decode_path(path)
|
[^outer_form_name, key | path] = decode_path(original_path)
|
||||||
|
|
||||||
cond do
|
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) ->
|
attr = Ash.Resource.Info.attribute(changeset.resource, key) ->
|
||||||
current_value = Ash.Changeset.get_attribute(changeset, attr.name)
|
current_value = Ash.Changeset.get_attribute(changeset, attr.name)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue