Skip to content

Commit eba8cbf

Browse files
author
Jason Stiebs
committed
remove restrict/cascade errors
1 parent a66cbea commit eba8cbf

File tree

4 files changed

+7
-75
lines changed

4 files changed

+7
-75
lines changed

integration_test/hints_test.exs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,6 @@ defmodule Ecto.Integration.HintsTest do
66
alias Ecto.Integration.Post
77
alias Ecto.Integration.TestRepo
88

9-
test "join hints" do
10-
{:ok, _} = TestRepo.query("CREATE INDEX post_id_idx ON posts (id)")
11-
TestRepo.insert!(%Post{id: 1})
12-
13-
results =
14-
from(p in Post,
15-
join: p2 in Post,
16-
on: p.id == p2.id,
17-
hints: ["INDEXED BY post_id_idx"]
18-
)
19-
|> TestRepo.all()
20-
21-
assert [%Post{id: 1}] = results
22-
end
23-
249
test "from hints" do
2510
{:ok, _} = TestRepo.query("CREATE INDEX post_id_idx ON posts (id)")
2611
TestRepo.insert!(%Post{id: 1})

integration_test/test_helper.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ ExUnit.start(
108108
:alter_foreign_key,
109109
:assigns_id_type,
110110
:modify_column,
111+
:restrict,
111112

112113
# SQLite3 does not support the concat function
113114
:concat,
@@ -121,5 +122,8 @@ ExUnit.start(
121122
:selected_as_with_order_by,
122123
:selected_as_with_order_by_expression,
123124
:selected_as_with_having,
125+
126+
# Distinct with options not supported
127+
:distinct_count
124128
]
125129
)

lib/ecto/adapters/sqlite3/connection.ex

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,6 @@ defmodule Ecto.Adapters.SQLite3.Connection do
370370
## DDL
371371
##
372372

373-
@impl true
374-
def execute_ddl({_command, %Table{options: options}, _}) when is_list(options) do
375-
raise ArgumentError, "SQLite3 adapter does not support keyword lists in :options"
376-
end
377-
378373
@impl true
379374
def execute_ddl({:create, %Table{} = table, columns}) do
380375
{table, composite_pk_def} = composite_pk_definition(table, columns)
@@ -426,14 +421,7 @@ defmodule Ecto.Adapters.SQLite3.Connection do
426421
end
427422

428423
@impl true
429-
def execute_ddl({:drop, %Table{} = table, mode}) do
430-
if mode != [] do
431-
raise ArgumentError, """
432-
`#{inspect(mode)}` is not supported for DROP TABLE with SQLite3 \
433-
DROP TABLE #{table.name} cannot have options set.
434-
"""
435-
end
436-
424+
def execute_ddl({:drop, %Table{} = table, _mode}) do
437425
execute_ddl({:drop, table})
438426
end
439427

@@ -540,14 +528,7 @@ defmodule Ecto.Adapters.SQLite3.Connection do
540528
end
541529

542530
@impl true
543-
def execute_ddl({:drop, %Index{} = index, mode}) do
544-
if mode != [] do
545-
raise ArgumentError, """
546-
`#{inspect(mode)}` is not supported for DROP INDEX with SQLite3 \
547-
DROP INDEX #{index.name} cannot have options set.
548-
"""
549-
end
550-
531+
def execute_ddl({:drop, %Index{} = index, _mode}) do
551532
execute_ddl({:drop, index})
552533
end
553534

@@ -567,14 +548,7 @@ defmodule Ecto.Adapters.SQLite3.Connection do
567548
end
568549

569550
@impl true
570-
def execute_ddl({:drop_if_exists, %Index{} = index, mode}) do
571-
if mode != [] do
572-
raise ArgumentError, """
573-
`#{inspect(mode)}` is not supported for DROP INDEX with SQLite3 \
574-
DROP INDEX #{index.name} cannot have options set.
575-
"""
576-
end
577-
551+
def execute_ddl({:drop_if_exists, %Index{} = index, _mode}) do
578552
execute_ddl({:drop_if_exists, index})
579553
end
580554

test/ecto/adapters/sqlite3/connection_test.exs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,18 +2139,6 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
21392139
assert execute_ddl(drop) == [~s|DROP TABLE "foo"."posts"|]
21402140
end
21412141

2142-
test "drop table with cascade" do
2143-
drop = {:drop, table(:posts), :cascade}
2144-
2145-
assert_raise ArgumentError, fn ->
2146-
execute_ddl(drop)
2147-
end
2148-
2149-
assert_raise ArgumentError, fn ->
2150-
execute_ddl(drop)
2151-
end
2152-
end
2153-
21542142
test "alter table" do
21552143
alter =
21562144
{:alter, table(:posts),
@@ -2314,13 +2302,6 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
23142302
assert execute_ddl(drop) == [~s|DROP INDEX "foo"."posts$main"|]
23152303
end
23162304

2317-
test "drop index mode not supported" do
2318-
assert_raise ArgumentError, fn ->
2319-
drop = {:drop, index(:posts, [:id], name: "posts$main"), :restrict}
2320-
execute_ddl(drop)
2321-
end
2322-
end
2323-
23242305
test "drop index concurrently not supported" do
23252306
index = index(:posts, [:id], name: "posts$main")
23262307

@@ -2330,18 +2311,6 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
23302311
end
23312312
end
23322313

2333-
test "drop index with cascade" do
2334-
assert_raise ArgumentError, fn ->
2335-
drop = {:drop, index(:posts, [:id], name: "posts$main"), :cascade}
2336-
execute_ddl(drop)
2337-
end
2338-
2339-
assert_raise ArgumentError, fn ->
2340-
drop = {:drop, index(:posts, [:id], name: "posts$main", prefix: :foo), :cascade}
2341-
execute_ddl(drop)
2342-
end
2343-
end
2344-
23452314
test "drop constraint" do
23462315
assert_raise ArgumentError,
23472316
~r/SQLite3 does not support ALTER TABLE DROP CONSTRAINT./,

0 commit comments

Comments
 (0)