Skip to content

Commit

Permalink
simplify non-string missing field condition
Browse files Browse the repository at this point in the history
  • Loading branch information
valrus committed Dec 31, 2024
1 parent 342ac28 commit ef00b1c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions beets/dbcore/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,13 +1000,13 @@ def sort(self, objs: list[AnyModel]) -> list[AnyModel]:

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
Expand Down

0 comments on commit ef00b1c

Please sign in to comment.