improvement: always reselect positionally on embedded resources

This commit is contained in:
Zach Daniel 2024-05-07 22:05:50 -04:00
parent 48c6438212
commit 04b4769e87

View file

@ -1368,7 +1368,8 @@ defmodule Ash.Actions.Read do
pkey = Ash.Resource.Info.primary_key(original_query.resource)
# we have to assume they are all there and in the same order. Not my
# favorite thing, but no way around it in the short term.
if Enum.empty?(pkey) || missing_pkeys? do
if Ash.Resource.Info.embedded?(original_query.resource) || Enum.empty?(pkey) ||
missing_pkeys? do
Enum.zip_with([data, data_with_selected], fn [record, match] ->
record
|> Map.merge(Map.take(match, fields_from_data))