diff --git a/beets/library.py b/beets/library.py index 89ebeee6c..439df774e 100644 --- a/beets/library.py +++ b/beets/library.py @@ -880,7 +880,12 @@ def construct_query_part(query_part, default_fields, all_keys): # Path field. elif key.lower() == 'path' and 'path' in all_keys: - return PathQuery(pattern) + if query_class is SubstringQuery: + # By default, use special path matching logic. + return PathQuery(pattern) + else: + # Specific query type requested. + return query_class('path', pattern) # Other (recognized) field. elif key.lower() in all_keys: diff --git a/docs/changelog.rst b/docs/changelog.rst index 06d0c7600..d69ea2d35 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -9,6 +9,8 @@ Changelog * :doc:`/plugins/lyrics`: More improvements to the Google backend by Fabrice Laporte. * :doc:`/plugins/bpd`: Fix for a crash when searching, thanks to Simon Chopin. +* Regular expression queries (and other query types) over paths now work. + (Previously, special query types were ignored for the ``path`` field.) 1.2.1 (June 22, 2013) diff --git a/test/test_query.py b/test/test_query.py index 051d38310..be2e88d93 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -416,6 +416,12 @@ class PathQueryTest(unittest.TestCase, AssertsMixin): results = self.lib.items(q) self.assert_done(results) + def test_path_regex(self): + q = 'path::\\.mp3$' + results = self.lib.items(q) + self.assert_matched(results, 'path item') + self.assert_done(results) + class BrowseTest(unittest.TestCase, AssertsMixin): def setUp(self): self.lib = beets.library.Library(