mirror of
https://github.com/beetbox/beets.git
synced 2026-01-15 12:41:22 +01:00
Fix #1605: parsing bare + and - in queries
This commit is contained in:
parent
6bae8146bb
commit
f4a124e7e2
3 changed files with 13 additions and 1 deletions
|
|
@ -188,7 +188,11 @@ def parse_sorted_query(model_cls, parts, prefixes={}):
|
|||
))
|
||||
del subquery_parts[:]
|
||||
else:
|
||||
if part.endswith((u'+', u'-')) and u':' not in part:
|
||||
# Sort parts (1) end in + or -, (2) don't have a field, and
|
||||
# (3) consist of more than just the + or -.
|
||||
if part.endswith((u'+', u'-')) \
|
||||
and u':' not in part \
|
||||
and len(part) > 1:
|
||||
sort_parts.append(part)
|
||||
else:
|
||||
subquery_parts.append(part)
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ Fixes:
|
|||
encounters an error. :bug:`1592`
|
||||
* Case-insensitive path queries might have returned nothing because of a
|
||||
wrong SQL query.
|
||||
* Fix a crash when a query contains a "+" or "-" alone in a component.
|
||||
:bug:`1605`
|
||||
|
||||
|
||||
1.3.14 (August 2, 2015)
|
||||
|
|
|
|||
|
|
@ -518,6 +518,12 @@ class ParseSortedQueryTest(unittest.TestCase):
|
|||
self.assertIsInstance(s, dbcore.query.NullSort)
|
||||
self.assertEqual(len(q.subqueries), 3)
|
||||
|
||||
def test_only_direction(self):
|
||||
q, s = self.psq('-')
|
||||
self.assertIsInstance(q, dbcore.query.AndQuery)
|
||||
self.assertIsInstance(s, dbcore.query.NullSort)
|
||||
self.assertEqual(len(q.subqueries), 1)
|
||||
|
||||
|
||||
class ResultsIteratorTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue