Searching: Fix A (B) not being treated as A AND (B)

Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
Kovid Goyal 2018-04-29 15:13:27 +05:30
commit 64c375848b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 2 deletions

View File

@ -221,8 +221,8 @@ class Parser(object):
return ['and', lhs, self.and_expression()]
# Account for the optional 'and'
if (self.token_type() in [self.WORD, self.QUOTED_WORD] and
self.lcase_token() != 'or'):
if ((self.token_type() in [self.WORD, self.QUOTED_WORD] or self.token() == '(')
and self.lcase_token() != 'or'):
return ['and', lhs, self.and_expression()]
return lhs

View File

@ -322,6 +322,7 @@ class Tester(SearchQueryParser):
'author:S\\"calzi': {343},
'"S\\"calzi"': {343},
'M\\\\cMurtry': {427},
'author:Tolstoy (tag:txt OR tag:pdf)': set([55, 56]),
}
fields = {'title':0, 'author':1, 'publisher':2, 'tag':3}