Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter to AnonymizedFaker() and RegexGenerator() to generate only unique values #542

Closed
npatki opened this issue Aug 18, 2022 · 0 comments · Fixed by #548
Closed
Labels
feature request Request for a new feature
Milestone

Comments

@npatki
Copy link
Contributor

npatki commented Aug 18, 2022

Problem Description

To effectively use AnonymizedFaker and RegexGenerator on data such as primary keys, I need to ensure that the anonymized data created during the reverse_transform stage is unique.

Expected behavior

Parameters
Add parameter enforce_uniqueness that controls whether the data should be unique.

  • (default) False: No guarantees that the anonymized data is unique
  • True: Guarantee that the anonymized data will be unique

Functionality
If enforce_uniqueness=True then:

  • During reverse_transform: Ensure that the new, anonymized data is all unique. If it isn't possible to create the requested number of rows, then raise an error
Error: The Faker function you specified is not able to generate 1000 unique values. Please use a different Faker function for column ('user_id').

Error: The regex is not able to generate 1000 unique values. Please use a different regex for column ('user_id').

Backwards Compatibility

This change is backwards compatible.

The enforce_uniqueness parameter is optional and assumed to be False if it's not provided. This is the current functionality.

@npatki npatki added the feature request Request for a new feature label Aug 18, 2022
@npatki npatki added this to the 1.3.0 milestone Aug 18, 2022
@npatki npatki changed the title Add parameter to AnonymizedFaker() to generate only unique values Add parameter to AnonymizedFaker() and RegexGenerator() to generate only unique values Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant