Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ecto/repo/preloader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ defmodule Ecto.Repo.Preloader do
# If we are returning many results, we must sort by the key too
query =
case {card, query.combinations} do
{:many, [{kind, _} | []]} ->
{:many, [{kind, _} | _]} ->
raise ArgumentError,
"`#{kind}` queries must be wrapped inside of a subquery " <>
"when preloading a `has_many` or `many_to_many` association. " <>
Expand Down
5 changes: 5 additions & 0 deletions test/ecto/repo_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,11 @@ defmodule Ecto.RepoTest do
TestRepo.preload(%MySchema{id: 1}, children: union(query, ^query))
end

assert_raise ArgumentError, msg, fn ->
combination_query = query |> union(^query) |> union(^query)
TestRepo.preload(%MySchema{id: 1}, children: combination_query)
end

msg = ~r"`union_all` queries must be wrapped inside of a subquery"

assert_raise ArgumentError, msg, fn ->
Expand Down
Loading