Add @schema_redact: :all_except_primary_keys module attribute to Ecto Schema#4599
Merged
josevalim merged 4 commits intoelixir-ecto:masterfrom Apr 6, 2025
Merged
Conversation
|
Fantastic! PKs by default sounds very reasonable. Thank you for working on this 💜 |
Member
|
Hi @Nezteb, in this case, I would call it Btw, implementation wise, I'd implement it here: https://github.com/elixir-ecto/ecto/blob/master/lib/ecto/schema.ex#L1995-L1997 So it does something like this: This way, you don't need to change changesets nor nothing else, we reuse the existing redact infrastructure. WDYT? |
Nezteb
commented
Apr 2, 2025
Nezteb
commented
Apr 2, 2025
josevalim
reviewed
Apr 3, 2025
b3638a7 to
6229c00
Compare
88b45ee to
d2642e8
Compare
Nezteb
commented
Apr 3, 2025
josevalim
reviewed
Apr 3, 2025
josevalim
reviewed
Apr 3, 2025
josevalim
reviewed
Apr 3, 2025
Member
|
💚 💙 💜 💛 ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Initial proposal: https://groups.google.com/g/elixir-ecto/c/kQJN-7HPn6E
@josevalim initially approved of the second of my two proposed options:
While implementing, I realized that it's probably not best to redact all fields. I opted to keep the primary keys of a schema even if
@schema_redactis set to something like:all, hence the rename to:all_except_primary_keys.TODO:
Future ideas:
@schema_redact: :all, but would that be useful?