Bug: Integer generation when constrained by lower or equal
lgeo3 opened this issue · 2 comments
lgeo3 commented
There seems to be an issue with the way constrained int are generated, so it seems to be impossible to get all possible values when for example we have a int with ge=1, and le=3
the possible values should be [1, 2, 3]
but with the generator we get only [1, 2]
for example
from pydantic import Field, BaseModel
from pydantic_factories import ModelFactory
class MyModel(BaseModel):
my_field: int = Field(ge=1, le=3)
class MyFactory(ModelFactory):
__model__ = MyModel
MyFactory.build()
I think it can be solved by replacing int casting by round function here
What do you think ?
Goldziher commented
Well, we should definitely check it out 😁.
Currently we've begun work on V2. So we will aim to fix this as part of that.
Goldziher commented
please check this against main and see if this is still a problem