Skip to content

Commit 71dc1f0

Browse files
authored
chore: Typos & more explicit include code (#358)
This ensures that: includes include_a: [include_a: [:include_a]] is the same as includes include_a: [include_a: [include_a: []]] It was already the case but this makes it explicit.
1 parent 4e8277f commit 71dc1f0

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/ash_json_api/includes/includer.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ defmodule AshJsonApi.Includes.Includer do
1313

1414
def get_includes(records, %Request{includes_keyword: includes_keyword})
1515
when is_list(records) do
16-
{record, includes_map} = get_includes_map(records, includes_keyword)
17-
{record, Map.values(includes_map)}
16+
{records, includes_map} = get_includes_map(records, includes_keyword)
17+
{records, Map.values(includes_map)}
1818
end
1919

2020
def get_includes(%{results: results} = paginator, request) do
@@ -28,14 +28,14 @@ defmodule AshJsonApi.Includes.Includer do
2828
{record, includes}
2929
end
3030

31-
defp get_includes_map(preloaded, include_keyword, includes_map \\ %{})
31+
defp get_includes_map(preloaded, includes_keyword, includes_map \\ %{})
3232
defp get_includes_map(related, [], includes_map), do: {related, includes_map}
3333

3434
defp get_includes_map(preloaded, %Ash.Query{load: load}, includes_map),
3535
do: get_includes_map(preloaded, load, includes_map)
3636

37-
defp get_includes_map(preloaded, include_keyword, includes_map) do
38-
include_keyword
37+
defp get_includes_map(preloaded, includes_keyword, includes_map) do
38+
includes_keyword
3939
|> Enum.reduce({preloaded, includes_map}, fn
4040
{relationship, further}, {preloaded_without_linkage, includes_map} ->
4141
{related, includes_map} =

lib/ash_json_api/includes/parser.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ defmodule AshJsonApi.Includes.Parser do
2929
|> to_nested_map()
3030
end
3131

32+
defp to_nested_map([]), do: true
33+
3234
defp to_nested_map(list) when is_list(list) do
3335
list
3436
|> Enum.map(fn

0 commit comments

Comments
 (0)