From 379dd0df6289c69bcb7413236d96cb06345f463f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Mon, 19 Oct 2026 12:53:22 +0200 Subject: [PATCH] Document that a custom Inspect implementation shows redacted fields Fields marked with `redact: true` are only excluded from inspect on the schema when Ecto derives Inspect for it. When the schema derives or implements Inspect itself, that implementation is used and redacted fields are shown unless it excludes them. --- lib/ecto/schema.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ecto/schema.ex b/lib/ecto/schema.ex index b293e11e5b..1026f99a71 100644 --- a/lib/ecto/schema.ex +++ b/lib/ecto/schema.ex @@ -127,8 +127,10 @@ defmodule Ecto.Schema do A field marked with `redact: true` will display a value of `**redacted**` when inspected in changes inside a `Ecto.Changeset` and be excluded from - inspect on the schema unless the schema module is tagged with - the option `@derive_inspect_for_redacted_fields false`. + inspect on the schema, unless the schema derives or implements `Inspect` + itself or the schema module is tagged with `@derive_inspect_for_redacted_fields false`. + A schema that derives `Inspect` itself must exclude redacted fields + explicitly, for example with `@derive {Inspect, except: [:password]}`. A schema module tagged with `@schema_redact :all_except_primary_keys` will redact all fields except primary keys.