feat(anonymize): add NULL, NAME, PHONE_NUMBER, DATE_OF_BIRTH, TEXT, WORD types#38
Merged
Merged
Conversation
…ORD types `anonymize` previously supported only `EMAIL`. To cover more PII columns without falling back to custom SQL post-steps, extend `FieldType` with: - `NULL` — blank the column. Useful for hashes / tokens / anything that shouldn't carry information in a shared dump. Note YAML's bare `NULL` parses as null, so quote the type: `type: "NULL"`. - `FIRST_NAME`, `LAST_NAME`, `NAME` — `faker.first_name()` / `last_name()` / `name()`. - `PHONE_NUMBER` — `faker.phone_number()`. - `DATE_OF_BIRTH` — `faker.date_of_birth()`, accepts `minimum_age` / `maximum_age`. - `TEXT`, `WORD` — `faker.text()` / `faker.word()`. All types forward their extra_args to the underlying Faker call, so the existing `EMAIL` `domain:` pattern works for the new types where Faker exposes options. Tests: 7 new parametrized cases over `_get_fake_value` plus an explicit check that an unknown type raises `ValueError`. README: new "3. Anonymization" section with the type table + an example config; subsequent sections renumbered.
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.
Summary
anonymizepreviously supported onlyEMAIL. This extendsFieldTypeso config files can cover more PII columns without falling back to custom SQL post-steps:NULL— blank the column. Useful for hashes / tokens / anything that shouldn't carry information in a shared dump.FIRST_NAME,LAST_NAME,NAME—faker.first_name()/last_name()/name().PHONE_NUMBER—faker.phone_number().DATE_OF_BIRTH—faker.date_of_birth(), acceptsminimum_age/maximum_ageextra args.TEXT,WORD—faker.text()/faker.word().All types forward their
extra_argsto the underlying Faker call, so the existingEMAILdomain:pattern works for the new ones too.Heads-up
YAML's bare
NULLparses as a real null, so users need to quote the type:Documented in the README example.
Tests
_get_fake_value(one per supported type) verifying the output matches the type's shape.pytest.raises(ValueError, match="unimplemented field type")to keep the fallback honest.Test plan