From ef00b1cd222024dc75b9c1f98e96e4c9b1cc1128 Mon Sep 17 00:00:00 2001 From: valrus Date: Tue, 31 Dec 2024 15:13:00 -0800 Subject: [PATCH] simplify non-string missing field condition --- beets/dbcore/query.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/beets/dbcore/query.py b/beets/dbcore/query.py index 5af1cc417..866162c4a 100644 --- a/beets/dbcore/query.py +++ b/beets/dbcore/query.py @@ -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