Fix #9397 (Search Replace error on custom field).

This commit is contained in:
Kovid Goyal 2011-03-14 10:14:45 -06:00
commit 4e777c6553
2 changed files with 17 additions and 3 deletions

View File

@ -783,6 +783,12 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
books_to_refresh = self.db.set_custom(id, val, label=dfm['label'], books_to_refresh = self.db.set_custom(id, val, label=dfm['label'],
extra=extra, commit=False, extra=extra, commit=False,
allow_case_change=True) allow_case_change=True)
elif dest.startswith('#') and dest.endswith('_index'):
label = self.db.field_metadata[dest[:-6]]['label']
series = self.db.get_custom(id, label=label, index_is_id=True)
books_to_refresh = self.db.set_custom(id, series, label=label,
extra=val, commit=False,
allow_case_change=True)
else: else:
if dest == 'comments': if dest == 'comments':
setter = self.db.set_comment setter = self.db.set_comment

View File

@ -123,14 +123,22 @@ REGEXP_MATCH = 2
def _match(query, value, matchkind): def _match(query, value, matchkind):
if query.startswith('..'): if query.startswith('..'):
query = query[1:] query = query[1:]
prefix_match_ok = False sq = query[1:]
internal_match_ok = True
else: else:
prefix_match_ok = True internal_match_ok = False
for t in value: for t in value:
t = icu_lower(t) t = icu_lower(t)
try: ### ignore regexp exceptions, required because search-ahead tries before typing is finished try: ### ignore regexp exceptions, required because search-ahead tries before typing is finished
if (matchkind == EQUALS_MATCH): if (matchkind == EQUALS_MATCH):
if prefix_match_ok and query[0] == '.': if internal_match_ok:
if query == t:
return True
comps = [c.strip() for c in t.split('.') if c.strip()]
for comp in comps:
if sq == comp:
return True
elif query[0] == '.':
if t.startswith(query[1:]): if t.startswith(query[1:]):
ql = len(query) - 1 ql = len(query) - 1
if (len(t) == ql) or (t[ql:ql+1] == '.'): if (len(t) == ql) or (t[ql:ql+1] == '.'):