-
-
Notifications
You must be signed in to change notification settings - Fork 512
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
Unique constraint on Faker objects #251
Comments
Hi Bart, My initial thoughts are, while a great idea; though, in practice, uniqueness is a complex topic and sometimes ambiguous.
Even if there was a way for developers to identify what properties of
Is it sufficient that And, user-defined types:
Next, let's consider the implementation details. As far as I know, there are two ways to go about implementing uniqueness:
Finally, concepts of uniqueness, object identity, database identity come up in ORMs all the time. So, I don't think this is a problem Bogus should attempt to solve wholesale. Last but not least, getting theoretical, if I recall correctly, eventually all sequences derived from a pseudo-random number generator (PRNG) eventually repeat. So, we might be hitting our heads against theoretical and mathematical computing limits when it comes to deriving uniqueness from deterministic PRNGs. As one might say, a fruitless endeavor. So, those are my thoughts... please feel free to carry on the conversation after I close the issue. Thanks, |
Context
More often than not, I've ran into issues with using Bogus and tests where they could succeeed locally and randomly fail on the build server because of an unique constraint on the in memory database.
Any idea could be to allow the user of the library to say that a rule should only produce unique values. For example the methode signature could be
Alternatives
As provided in #152 the UniqueIndex could be used to make some output data unique.
But this doesn't seem as intuitive as a more generalized solution as some generated values might not benefit from a UniqueIndex.
Has the feature been requested before?
152
If the feature request is approved, would you be willing to submit a PR?
Yes /
No (Help can be provided if you need assistance submitting a PR)The text was updated successfully, but these errors were encountered: