Skip to content

Commit

Permalink
Improve ordering enum name
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSuperiorStanislav committed Apr 2, 2024
1 parent f9cecc5 commit 6b2b80d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fastapi_rest_framework/sqlalchemy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ def get_ordering_enum(
ordering_fields: collections.abc.Sequence[str],
) -> type[enum.StrEnum]:
"""Prepare ordering enum."""
model_name = getattr(self.model.__table__, "name", None)
enum_name = "OrderingEnum"
if model_name:
enum_name = f"{str(model_name).capitalize()}{enum_name}"
return saritasa_sqlalchemy_tools.OrderingEnum( # type: ignore
"OrderingEnum",
enum_name,
ordering_fields,
)

Expand Down

0 comments on commit 6b2b80d

Please sign in to comment.