mirror of
https://github.com/beetbox/beets.git
synced 2025-12-16 05:34:47 +01:00
Explicitly let artpath be missing
We really want `Album.artpath` to be None sometimes, and this was relying on some accidental dbcore behavior before. Now, we explicitly mark the field as nullable: it may be a path, or it may be None to indicate that there is no art.
This commit is contained in:
parent
2a9be17cf6
commit
41bd6f9a97
1 changed files with 18 additions and 1 deletions
|
|
@ -144,10 +144,27 @@ class DateType(types.Float):
|
|||
|
||||
|
||||
class PathType(types.Type):
|
||||
"""A dbcore type for filesystem paths. These are represented as
|
||||
`bytes` objects, in keeping with the Unix filesystem abstraction.
|
||||
"""
|
||||
|
||||
sql = u'BLOB'
|
||||
query = PathQuery
|
||||
model_type = bytes
|
||||
|
||||
def __init__(self, nullable=False):
|
||||
"""Create a path type object. `nullable` controls whether the
|
||||
type may be missing, i.e., None.
|
||||
"""
|
||||
self.nullable = nullable
|
||||
|
||||
@property
|
||||
def null(self):
|
||||
if self.nullable:
|
||||
return None
|
||||
else:
|
||||
return b''
|
||||
|
||||
def format(self, value):
|
||||
return util.displayable_path(value)
|
||||
|
||||
|
|
@ -873,7 +890,7 @@ class Album(LibModel):
|
|||
_always_dirty = True
|
||||
_fields = {
|
||||
'id': types.PRIMARY_ID,
|
||||
'artpath': PathType(),
|
||||
'artpath': PathType(True),
|
||||
'added': DateType(),
|
||||
|
||||
'albumartist': types.STRING,
|
||||
|
|
|
|||
Loading…
Reference in a new issue