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

fix language factory possible languageCode collision #1778

Open
wants to merge 6 commits into
base: 1.x
Choose a base branch
from

Conversation

wychoong
Copy link
Contributor

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

Copy link

vercel bot commented May 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 3:00am

@alecritson
Copy link
Collaborator

Thanks @wychoong

Not sure this is entirely needed, In your loop could you not just override the code yourself?

@wychoong
Copy link
Contributor Author

wychoong commented Jun 6, 2024

Thanks @wychoong

Not sure this is entirely needed, In your loop could you not just override the code yourself?

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(),
        ])

@glennjacobs glennjacobs added this to the v1.0 milestone Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants