Closed vickypalani closed 4 months ago
Can you try this?
from polyfactory import Use
class RoleTypeFactory(BaseFactory):
"""
RoleType Factory
"""
__model__ = neo_hire_models.RoleType
id = Ignore()
name = Use(lambda: Faker().name())
I would recommend name = Use(lambda: RoleTypeFactory.__faker__.name())
instead of creating your own faker
Hi, I recently started working on a FastAPI project where I needed to create dummy data for a SQLAlchemy model that has a unique field. This is my code to implement it.
When I try to create a batch like this,
await RoleTypeFactory.create_batch_async(size=5)
I get an issue since the name field uses the same value for all the instances, thus triggering the UniqueConstraint error. This is my SQLAlchemyModel for reference