From a01ea673a5148aa1e80e004bbcbf6257b6836f6f Mon Sep 17 00:00:00 2001 From: Lukasz Samson Date: Sat, 4 Jul 2026 11:57:24 +0200 Subject: [PATCH] Match on correct tuple shape in insert_all placeholder type mismatch check Fixes #4742 --- lib/ecto/repo/schema.ex | 2 +- test/ecto/repo_test.exs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ecto/repo/schema.ex b/lib/ecto/repo/schema.ex index 784665acb1..730e50a933 100644 --- a/lib/ecto/repo/schema.ex +++ b/lib/ecto/repo/schema.ex @@ -285,7 +285,7 @@ defmodule Ecto.Repo.Schema do %{^key => {idx, ^type, _, _}} -> {{:placeholder, idx}, placeholder_dump, counter} - %{^key => {_, type, _}} -> + %{^key => {_, type, _, _}} -> raise ArgumentError, "a placeholder key can only be used with columns of the same type. " <> "The key #{inspect(key)} has already been dumped as a #{inspect(type)}" diff --git a/test/ecto/repo_test.exs b/test/ecto/repo_test.exs index 7a2141d584..d4bafe59bd 100644 --- a/test/ecto/repo_test.exs +++ b/test/ecto/repo_test.exs @@ -960,9 +960,9 @@ defmodule Ecto.RepoTest do test "Repo.insert_all raises when placeholder key is used for different types" do placeholders = %{uuid_key: Ecto.UUID.generate()} ph_key = {:placeholder, :uuid_key} - entries = [%{bid: ph_key, string: ph_key}] + entries = [%{bid: ph_key, str: ph_key}] - assert_raise ArgumentError, fn -> + assert_raise ArgumentError, ~r/a placeholder key can only be used with columns of the same type/, fn -> TestRepo.insert_all(MySchemaWithBinaryId, entries, placeholders: placeholders) end end