Skip to content

Commit 412faf2

Browse files
committed
Remove requirement that on_writable_violation must be :nothing for writable: :always
1 parent acde79b commit 412faf2

2 files changed

Lines changed: 0 additions & 28 deletions

File tree

lib/ecto/schema.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,10 +2078,6 @@ defmodule Ecto.Schema do
20782078
raise ArgumentError, "autogenerated fields must always be writable"
20792079
end
20802080

2081-
if writable == :always and on_writable_violation != :nothing do
2082-
raise ArgumentError, "on_writable_violation must be :nothing for always writable fields"
2083-
end
2084-
20852081
if pk? do
20862082
Module.put_attribute(mod, :ecto_primary_keys, name)
20872083
end

test/ecto/schema_test.exs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -718,30 +718,6 @@ defmodule Ecto.SchemaTest do
718718
end
719719
end
720720

721-
test "invalid on_writable_violation for writable" do
722-
assert_raise ArgumentError, "on_writable_violation must be :nothing for always writable fields",
723-
fn ->
724-
defmodule OnWritableViolationFail do
725-
use Ecto.Schema
726-
727-
schema "hello" do
728-
field :x, :string, writable: :always, on_writable_violation: :warn
729-
end
730-
end
731-
end
732-
733-
assert_raise ArgumentError, "on_writable_violation must be :nothing for always writable fields",
734-
fn ->
735-
defmodule OnWritableViolationFail do
736-
use Ecto.Schema
737-
738-
schema "hello" do
739-
field :x, :string, writable: :always, on_writable_violation: :raise
740-
end
741-
end
742-
end
743-
end
744-
745721
test "inline embed defined without schema" do
746722
# embeds_one
747723
message = ~r"`embeds_one/3` expects `schema` to be a module name, but received \[do:"

0 commit comments

Comments
 (0)