diff --git a/beets/dbcore/types.py b/beets/dbcore/types.py index de05fc9f4..80f1d8714 100644 --- a/beets/dbcore/types.py +++ b/beets/dbcore/types.py @@ -385,7 +385,10 @@ class BasePathType(Type[bytes, N]): return value def from_sql(self, sql_value: SQLiteType) -> bytes | N: - return pathutils.expand_path_from_db(self.normalize(sql_value)) + value = self.normalize(sql_value) + if isinstance(value, bytes): + return pathutils.expand_path_from_db(value) + return value def to_sql(self, value: pathutils.MaybeBytes) -> BLOB_TYPE | None: value = pathutils.normalize_path_for_db(value) @@ -451,7 +454,7 @@ class DurationType(Float): def format(self, value: float) -> str: if not beets.config["format_raw_length"].get(bool): return human_seconds_short(value or 0.0) - return value + return str(value) def parse(self, string: str) -> float | N: try: diff --git a/test/dbcore/test_types.py b/test/dbcore/test_types.py index aa5b5e7c2..4eaab05d3 100644 --- a/test/dbcore/test_types.py +++ b/test/dbcore/test_types.py @@ -56,8 +56,8 @@ def test_durationtype(): assert t.null == t.parse("not61.23") # config format_raw_length beets.config["format_raw_length"] = True - assert 61.23 == t.format(61.23) - assert 3601.23 == t.format(3601.23) + assert "61.23" == t.format(61.23) + assert "3601.23" == t.format(3601.23) @pytest.mark.parametrize(