Skip to content

Commit

Permalink
Show ... on inspect for consistency with latest Elixir
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Mar 30, 2024
1 parent ffaf69a commit ff4bbd3
Show file tree
Hide file tree
Showing 2 changed files with 1,460 additions and 420 deletions.
13 changes: 7 additions & 6 deletions lib/ecto/changeset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4173,8 +4173,9 @@ defimpl Inspect, for: Ecto.Changeset do
import Inspect.Algebra

def inspect(%Ecto.Changeset{data: data} = changeset, opts) do
# The trailing element is skipped later on
list =
for attr <- [:action, :changes, :errors, :data, :valid?] do
for attr <- [:action, :changes, :errors, :data, :valid?, :action] do
{attr, Map.get(changeset, attr)}
end

Expand All @@ -4191,20 +4192,20 @@ defimpl Inspect, for: Ecto.Changeset do
[]
end

container_doc("#Ecto.Changeset<", list, ">", opts, fn
{:action, action}, opts ->
container_doc("#Ecto.Changeset<", list, ">", %{limit: 5}, fn
{:action, action}, _opts ->
concat("action: ", to_doc(action, opts))

{:changes, changes}, opts ->
{:changes, changes}, _opts ->
concat("changes: ", changes |> filter(redacted_fields) |> to_doc(opts))

{:data, data}, _opts ->
concat("data: ", to_struct(data, opts))

{:errors, errors}, opts ->
{:errors, errors}, _opts ->
concat("errors: ", to_doc(errors, opts))

{:valid?, valid?}, opts ->
{:valid?, valid?}, _opts ->
concat("valid?: ", to_doc(valid?, opts))
end)
end
Expand Down
Loading

0 comments on commit ff4bbd3

Please sign in to comment.