From 65180ec3acc6d2559a3ca78b605db659054b1eac Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Fri, 5 Jan 2024 10:01:40 -0500 Subject: [PATCH] fix: honor configured schema on bulk create --- lib/data_layer.ex | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/data_layer.ex b/lib/data_layer.ex index 3e266b34..c4d8661c 100644 --- a/lib/data_layer.ex +++ b/lib/data_layer.ex @@ -1400,6 +1400,13 @@ defmodule AshPostgres.DataLayer do resource end + opts = + if schema = Enum.at(changesets, 0).context[:data_layer][:schema] do + Keyword.put(opts, :prefix, schema) + else + opts + end + result = with_savepoint(repo, opts[:on_conflict], fn -> repo.insert_all(source, ecto_changesets, opts)