diff --git a/beets/library.py b/beets/library.py index 7167bb267..6695c9ede 100644 --- a/beets/library.py +++ b/beets/library.py @@ -164,8 +164,10 @@ def _regexp(expr, val): """Return a boolean indicating whether the regular expression `expr` matches `val`. """ - if val is None or expr is None: + if expr is None: return False + if val is None: + val = u'' if not isinstance(val, basestring): val = unicode(val) try: @@ -409,8 +411,6 @@ class FieldQuery(Query): pattern. """ def __init__(self, field, pattern): - if field not in ITEM_KEYS: - raise InvalidFieldError(field + ' is not an item key') self.field = field self.pattern = pattern @@ -607,10 +607,10 @@ class CollectionQuery(Query): # Unicode strings. # http://bugs.python.org/issue6988 if isinstance(query, unicode): - pass query = query.encode('utf8') parts = [s.decode('utf8') for s in shlex.split(query)] - return cls.from_strings(parts) + return cls.from_strings(parts, default_fields=default_fields, + all_keys=all_keys) class AnySubstringQuery(CollectionQuery): """A query that matches a substring in any of a list of metadata diff --git a/docs/changelog.rst b/docs/changelog.rst index 46951c677..4ace620a0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,6 +6,9 @@ Changelog * ``list`` command: Templates given with ``-f`` can now show items' paths (using ``$path``). +* Fix album queries for ``artpath`` and other non-item fields. +* Null values in the database can now be matched with the empty-string regular + expression, ``^$``. * :doc:`/plugins/fetchart`: Fix a bug where cover art filenames could lack a ``.jpg`` extension. * Add the track mapping dictionary to the ``album_distance`` plugin function.