Skip to content

Commit e239cef

Browse files
authored
Merge branch 'master' into dbern/safe-ecto-migration
2 parents 647b502 + b1f477c commit e239cef

6 files changed

Lines changed: 19 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
* [sandbox] Label the sandbox owner process
1010
* [sql] Allow fragment tuple sources in adapters
1111

12+
## v3.13.5 (2026-03-03)
13+
14+
* [postgrex] Map `:restrict_violation` to `:foreign_key` constraint (required by PostgreSQL 18)
15+
1216
## v3.13.4 (2025-12-27)
1317

1418
### Bug fixes

lib/ecto/adapters/postgres/connection.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,9 @@ if Code.ensure_loaded?(Postgrex) do
12041204
defp returning([]),
12051205
do: []
12061206

1207+
defp returning({:unsafe_fragment, fragment}),
1208+
do: [" RETURNING ", fragment]
1209+
12071210
defp returning(returning),
12081211
do: [" RETURNING " | quote_names(returning)]
12091212

lib/ecto/adapters/sql.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ defmodule Ecto.Adapters.SQL do
895895
{name, config} = Keyword.pop(config, :name, config[:repo])
896896
{pool_count, config} = Keyword.pop(config, :pool_count, 1)
897897
{pool, config} = pool_config(config)
898-
child_spec = connection.child_spec(config)
898+
child_spec = connection.child_spec([label: name] ++ config)
899899

900900
meta = %{
901901
telemetry: telemetry,

lib/ecto/adapters/tds/connection.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,9 @@ if Code.ensure_loaded?(Tds) do
10271027

10281028
defp returning([], _verb), do: []
10291029

1030+
defp returning({:unsafe_fragment, fragment}, _verb),
1031+
do: [" OUTPUT ", fragment]
1032+
10301033
defp returning(returning, verb) when is_list(returning) do
10311034
[" OUTPUT ", Enum.map_intersperse(returning, ", ", &[verb, ?., quote_name(&1)])]
10321035
end

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
88
"earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"},
99
"ecto": {:git, "https://github.com/elixir-ecto/ecto.git", "bf242348cdf89c056a977668da707b9937208efe", [branch: "master"]},
10-
"ex_doc": {:hex, :ex_doc, "0.39.3", "519c6bc7e84a2918b737aec7ef48b96aa4698342927d080437f61395d361dcee", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "0590955cf7ad3b625780ee1c1ea627c28a78948c6c0a9b0322bd976a079996e1"},
10+
"ex_doc": {:hex, :ex_doc, "0.40.1", "67542e4b6dde74811cfd580e2c0149b78010fd13001fda7cfeb2b2c2ffb1344d", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "bcef0e2d360d93ac19f01a85d58f91752d930c0a30e2681145feea6bd3516e00"},
1111
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
1212
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
1313
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},

test/ecto/adapters/postgres_test.exs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,13 @@ defmodule Ecto.Adapters.PostgresTest do
18771877

18781878
query = insert("prefix", "schema", [], [[]], {:raise, [], []}, [])
18791879
assert query == ~s{INSERT INTO "prefix"."schema" VALUES (DEFAULT)}
1880+
1881+
# With unsafe_fragment in returning
1882+
fragment = ~s{"id", ("x" = "y") AS "was_equal"}
1883+
query = insert("prefix", "schema", [], [[]], {:raise, [], []}, {:unsafe_fragment, fragment})
1884+
1885+
assert query ==
1886+
~s{INSERT INTO "prefix"."schema" VALUES (DEFAULT) RETURNING #{fragment}}
18801887
end
18811888

18821889
test "insert with on conflict" do

0 commit comments

Comments
 (0)