-
Notifications
You must be signed in to change notification settings - Fork 371
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
fix language factory possible languageCode collision #1778
base: 1.x
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks @wychoong Not sure this is entirely needed, In your loop could you not just override the |
The problem is when create a product with the factory, if no language id is provided to url factory, it will trigger the language factory. So when create multiple products, it might hit the constraint. And in my test suite setup I configured a seeder to create language for convenience with getDefault(). But now chances of hitting the constraint is even higher. However to always pass a language id when creating products is unnecessary when language is not a concern in the test case. Product::factory()
->hasUrls(1, [
'default' => true,
// 'language_id' => Language::getDefault(),
]) |
when running test, when have enough iteration (eg: ->repeat(50)) there is a possibility of hitting UniqueConstraintViolationException
changing from
->unique()->languageCode
to->slug()
fixes this as its not a fixed set of language codes