Skip to content

Commit d1a399c

Browse files
committed
Add more ON DELETE SET DEFAULT tests for PG and TDS
1 parent 243d310 commit d1a399c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

test/ecto/adapters/postgres_test.exs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2234,6 +2234,12 @@ defmodule Ecto.Adapters.PostgresTest do
22342234
}, []},
22352235
{:add, :category_15, %Reference{table: :categories, on_delete: :default_all}, []},
22362236
{:add, :category_16,
2237+
%Reference{
2238+
table: :categories,
2239+
with: [here: :there, here2: :there2],
2240+
on_delete: :default_all
2241+
}, []},
2242+
{:add, :category_17,
22372243
%Reference{
22382244
table: :categories,
22392245
with: [here: :there, here2: :there2],
@@ -2260,7 +2266,8 @@ defmodule Ecto.Adapters.PostgresTest do
22602266
"category_13" bigint, CONSTRAINT "posts_category_13_fkey" FOREIGN KEY ("category_13","here") REFERENCES "categories"("id","there") MATCH FULL ON UPDATE RESTRICT,
22612267
"category_14" bigint, CONSTRAINT "posts_category_14_fkey" FOREIGN KEY ("category_14","here","here2") REFERENCES "categories"("id","there","there2") ON DELETE SET NULL ("here","here2"),
22622268
"category_15" bigint, CONSTRAINT "posts_category_15_fkey" FOREIGN KEY ("category_15") REFERENCES "categories"("id") ON DELETE SET DEFAULT,
2263-
"category_16" bigint, CONSTRAINT "posts_category_16_fkey" FOREIGN KEY ("category_16","here","here2") REFERENCES "categories"("id","there","there2") ON DELETE SET DEFAULT ("here","here2"),
2269+
"category_16" bigint, CONSTRAINT "posts_category_16_fkey" FOREIGN KEY ("category_16","here","here2") REFERENCES "categories"("id","there","there2") ON DELETE SET DEFAULT,
2270+
"category_17" bigint, CONSTRAINT "posts_category_17_fkey" FOREIGN KEY ("category_17","here","here2") REFERENCES "categories"("id","there","there2") ON DELETE SET DEFAULT ("here","here2"),
22642271
PRIMARY KEY ("id"))
22652272
"""
22662273
|> remove_newlines

test/ecto/adapters/tds_test.exs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,10 @@ defmodule Ecto.Adapters.TdsTest do
14831483
{:add, :category_5,
14841484
%Reference{table: :categories, options: [prefix: "foo"], on_delete: :nilify_all}, []},
14851485
{:add, :category_6,
1486-
%Reference{table: :categories, with: [here: :there], on_delete: :nilify_all}, []}
1486+
%Reference{table: :categories, with: [here: :there], on_delete: :nilify_all}, []},
1487+
{:add, :category_7, %Reference{table: :categories, on_delete: :default_all}, []},
1488+
{:add, :category_8,
1489+
%Reference{table: :categories, with: [here: :there], on_delete: :default_all}, []}
14871490
]}
14881491

14891492
assert execute_ddl(create) == [
@@ -1503,6 +1506,10 @@ defmodule Ecto.Adapters.TdsTest do
15031506
CONSTRAINT [posts_category_5_fkey] FOREIGN KEY ([category_5]) REFERENCES [foo].[categories]([id]) ON DELETE SET NULL ON UPDATE NO ACTION,
15041507
[category_6] BIGINT,
15051508
CONSTRAINT [posts_category_6_fkey] FOREIGN KEY ([category_6],[here]) REFERENCES [categories]([id],[there]) ON DELETE SET NULL ON UPDATE NO ACTION,
1509+
[category_7] BIGINT,
1510+
CONSTRAINT [posts_category_7_fkey] FOREIGN KEY ([category_7]) REFERENCES [categories]([id]) ON DELETE SET DEFAULT ON UPDATE NO ACTION,
1511+
[category_8] BIGINT,
1512+
CONSTRAINT [posts_category_8_fkey] FOREIGN KEY ([category_8],[here]) REFERENCES [categories]([id],[there]) ON DELETE SET DEFAULT ON UPDATE NO ACTION,
15061513
CONSTRAINT [posts_pkey] PRIMARY KEY CLUSTERED ([id]));
15071514
"""
15081515
|> remove_newlines

0 commit comments

Comments
 (0)