Skip to content

Commit

Permalink
fix(sqla_factory): fixed handling SQLA column constraints (litestar-o…
Browse files Browse the repository at this point in the history
  • Loading branch information
nisemenov committed Jan 31, 2025
1 parent 9332fa8 commit fcc9976
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions polyfactory/factories/sqlalchemy_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def _get_type_from_type_engine(cls, type_engine: TypeEngine) -> type:
for sqlalchemy_field, constraint_field in constraint_fields.items():
if (value := getattr(type_engine, sqlalchemy_field, None)) is not None:
constraints[constraint_field] = value # type: ignore[literal-required]
if sqlalchemy_field == "precision":
constraints.setdefault("decimal_places", 0)
if constraints:
annotation = Annotated[annotation, Frozendict(constraints)] # type: ignore[assignment]

Expand Down

0 comments on commit fcc9976

Please sign in to comment.