Skip to content

Commit 6f8697c

Browse files
committed
Properly format :in composite types, closes #4672
1 parent 0511206 commit 6f8697c

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/ecto/type.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ defmodule Ecto.Type do
106106
>
107107
> When you `use Ecto.Type`, it will set `@behaviour Ecto.Type` and define
108108
> default, overridable implementations for `c:embed_as/1` and `c:equal?/2`.
109-
> You must implement your own `c:embed_as/1` function if you want
109+
> You must implement your own `c:embed_as/1` function if you want
110110
> your `c:dump/1` to be called when exporting from Ecto.
111111
112112
## Custom types and primary keys
@@ -1408,7 +1408,7 @@ defmodule Ecto.Type do
14081408
end
14091409
end
14101410

1411-
def format({composite, type}) when composite in [:array, :map] do
1411+
def format({composite, type}) when composite in [:array, :map, :in] do
14121412
"{#{inspect(composite)}, #{format(type)}}"
14131413
end
14141414

test/ecto/type_test.exs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,19 +1433,18 @@ defmodule Ecto.TypeTest do
14331433
assert Ecto.Type.format({:array, with_format_defined}) ==
14341434
"{:array, #CustomParameterizedTypeWithFormat<:custom>}"
14351435

1436-
assert Ecto.Type.format({:array, without_format_defined}) ==
1437-
"{:array, #Ecto.TypeTest.CustomParameterizedTypeWithoutFormat<%{}>}"
1436+
assert Ecto.Type.format({:in, without_format_defined}) ==
1437+
"{:in, #Ecto.TypeTest.CustomParameterizedTypeWithoutFormat<%{}>}"
14381438
end
14391439

14401440
test "non parameterized type" do
1441-
# fallback to `inspect(type)`
14421441
assert Ecto.Type.format(:id) == ":id"
14431442
end
14441443

14451444
test "composite non parameterized type" do
1446-
# fallback to `inspect(type)`
14471445
assert Ecto.Type.format({:array, :id}) == "{:array, :id}"
14481446
assert Ecto.Type.format({:array, {:map, :integer}}) == "{:array, {:map, :integer}}"
1447+
assert Ecto.Type.format({:in, :binary}) == "{:in, :binary}"
14491448
end
14501449
end
14511450

0 commit comments

Comments
 (0)