File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed
Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -1001,9 +1001,8 @@ defmodule Ecto.Type do
10011001 defp same_duration ( _ ) , do: :error
10021002
10031003 @ doc false
1004- def empty_trimmed? ( value , type ) do
1005- is_binary ( value ) and type != :binary and String . trim_leading ( value ) == ""
1006- end
1004+ def empty_trimmed? ( value , :binary ) , do: value == ""
1005+ def empty_trimmed? ( value , _type ) , do: is_binary ( value ) and String . trim_leading ( value ) == ""
10071006
10081007 ## Adapter related
10091008
Original file line number Diff line number Diff line change @@ -222,11 +222,11 @@ defmodule Ecto.ChangesetTest do
222222 test "cast/4: with binary empty values" do
223223 # <<9>> is a control character which should not be empty_trimmed
224224 # for a binary field
225- params = % { "color" => << 9 >> }
226- struct = % Post { }
225+ changeset = cast ( % Post { } , % { "color" => << 9 >> } , ~w ( color ) a )
226+ assert changeset . changes == % { color: << 9 >> }
227227
228- changeset = cast ( struct , params , ~w( color) a )
229- assert changeset . changes == % { "color": << 9 >> }
228+ changeset = cast ( % Post { } , % { "color" => << >> } , ~w( color) a )
229+ assert changeset . changes == % { }
230230 end
231231
232232 test "cast/4: with force_changes" do
You can’t perform that action at this time.
0 commit comments