mirror of
https://github.com/beetbox/beets.git
synced 2025-12-20 15:43:58 +01:00
simplify non-string missing field condition
This commit is contained in:
parent
342ac283b6
commit
ef00b1cd22
1 changed files with 5 additions and 5 deletions
|
|
@ -1000,13 +1000,13 @@ class FieldSort(Sort):
|
|||
|
||||
def key(obj: Model) -> Any:
|
||||
field_val = obj.get(self.field, None)
|
||||
# If the field is typed, use its null value.
|
||||
if field_val is None:
|
||||
if self.field in obj._types:
|
||||
if _type := obj._types.get(self.field):
|
||||
# If the field is typed, use its null value.
|
||||
field_val = obj._types[self.field].null
|
||||
# If not, or the null value is None, fall back to using an empty string.
|
||||
if field_val is None:
|
||||
field_val = ""
|
||||
else:
|
||||
# If not, fall back to using an empty string.
|
||||
field_val = ""
|
||||
if self.case_insensitive and isinstance(field_val, str):
|
||||
field_val = field_val.lower()
|
||||
return field_val
|
||||
|
|
|
|||
Loading…
Reference in a new issue