fix regex (and other) queries in path field

This commit is contained in:
Adrian Sampson 2013-08-04 13:12:25 -07:00
parent dfb7509540
commit c1b66105dd
3 changed files with 14 additions and 1 deletions

View file

@ -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:

View file

@ -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)

View file

@ -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(