Use `Path` in models while keeping SQL path storage as bytes
Author: snejusCreated Sep 1, 2026Updated Sep 29, 2026
Labelscore
Part of: #1409
Depends on: runtime callers preferring filepath and art_filepath.
Problem
The central model type still exposes path fields as byte-oriented values, while the long-term runtime contract should be Path. At the same time, #1409 identified that SQLite should continue storing filesystem paths as bytes so surrogate escapes and existing database contents remain safe.
Expected behavior
PathTypeandNullPathTypeexposePathvalues to Python model code.- SQL serialization still stores path values as bytes/BLOBs.
- SQL deserialization expands stored relative paths into
Pathvalues. PathQuerycomparesPathvalues while generating SQL against the stored byte representation.- Legacy database contents and migration code continue to round-trip correctly.
LibModel.pathandAlbum.artpathcompatibility behavior is deliberately documented by tests.
Suggested fix
Move encoding and decoding into dbcore path type/query helpers. Runtime model code should see Path; SQLite should see the same byte representation beets already relies on.
Acceptance criteria
- Model path fields are
Pathat the Python boundary. - Stored SQL values remain bytes/BLOBs.
- Tests cover relative path storage, database round trips, legacy rows, query matching, and undecodable path behavior.
poe testandpoe lintpass with coverage at or above 80%.
Source: beetbox/beets