diff --git a/ormar/queryset/utils.py b/ormar/queryset/utils.py index 5520f67..9c84817 100644 --- a/ormar/queryset/utils.py +++ b/ormar/queryset/utils.py @@ -17,10 +17,12 @@ if TYPE_CHECKING: # pragma no cover from ormar import Model, BaseField -def to_str(val: Union[bytes, str]): +def to_str(val: Union[bytes, str, int]): """ convert bytes to str simply """ if isinstance(val, bytes): return val.decode("utf-8") + elif isinstance(val, str): + return val return str(val) diff --git a/tests/test_queries/test_utils.py b/tests/test_queries/test_utils.py index 893d4a9..8f2fac4 100644 --- a/tests/test_queries/test_utils.py +++ b/tests/test_queries/test_utils.py @@ -12,3 +12,4 @@ def test_to_str(): assert isinstance(expected_bytes, bytes) assert isinstance(to_str(expected_bytes), str) + assert "1" == to_str(1)