litestar-org/polyfactory

ormar Enum default ignored

eloi-martinez-qida opened this issue · 1 comments

Tbh i don't know if this is a bug or it's just outside the function of this library.

But when i build a factory of an ormar model with a defined default in the model its ignored and it sets it as random.

Example:

class TestState(Enum):
    NEW = 'NEW'
    OK = 'OK'
    ERROR = 'ERROR'

class TestModel:
    class Meta(BaseMeta):
        pass

    state: Enum = ormar.Enum(enum_class=TestState, default=TestState.NEW)
    
class TestModelFactory(OrmarModelFactory):
    __model__ = TestModel

The build factory has state=<TestState.OK: 'OK'>

Version: pydantic_factories-1.15.0

This is not in this library probably. You can define a default in the factory itself to resolve this. The default in ormar probably skips the Pydantic default.