Skip to content

Fix nil map merges #4601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 7, 2025
Merged
Changes from 1 commit
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
11 changes: 10 additions & 1 deletion lib/ecto/repo/queryable.ex
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ defmodule Ecto.Repo.Queryable do

defp process(row, {:merge, left, right}, from, adapter) do
{left, row} = process(row, left, from, adapter)
{right, row} = process(row, right, from, adapter)
{right, row} = process_merge(row, right, from, adapter)

data =
case {left, right} do
Expand Down Expand Up @@ -427,6 +427,15 @@ defmodule Ecto.Repo.Queryable do
end)
end

defp process_merge(row, {:source, {source, schema}, prefix, types}, _from, adapter) do
struct = Ecto.Schema.Loader.load_struct(schema, prefix, source)
struct_load!(types, row, [], false, struct, adapter)
end

defp process_merge(row, process, from, adapter) do
process(row, process, from, adapter)
end

@compile {:inline, load!: 5}
defp load!(type, value, field, struct, adapter) do
case Ecto.Type.adapter_load(adapter, type, value) do
Expand Down
Loading