From 3d38872b56da7cff99bad9f1cc66c9cd2896c16e Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Wed, 26 May 2010 14:48:53 +0100 Subject: [PATCH] Fix bareword searches trying to match against non-text types. --- src/calibre/library/caches.py | 7 +++++-- src/calibre/library/tag_categories.py | 16 ++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index d403c0e7ae..fa73b34b41 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -381,12 +381,17 @@ class ResultCache(SearchQueryParser): location += 's' MAP = {} + # Fields not used when matching against text contents. These are + # the non-text fields + EXCLUDE_FIELDS = [] # get the db columns for the standard searchables for x in self.tag_browser_categories: if (len(self.tag_browser_categories[x]['search_labels']) and \ self.tag_browser_categories[x]['kind'] in ['standard', 'not_cat']): MAP[x] = self.FIELD_MAP[self.tag_browser_categories.get_field_label(x)] + if self.tag_browser_categories[x]['datatype'] != 'text': + EXCLUDE_FIELDS.append(MAP[x]) # add custom columns to MAP. Put the column's type into IS_CUSTOM IS_CUSTOM = [] @@ -399,8 +404,6 @@ class ResultCache(SearchQueryParser): MAP[x] = self.FIELD_MAP[self.tag_browser_categories[x]['colnum']] IS_CUSTOM[MAP[x]] = self.tag_browser_categories[x]['datatype'] - # Some fields not used when matching against contents - EXCLUDE_FIELDS = [MAP['rating'], MAP['cover']] SPLITABLE_FIELDS = [MAP['authors'], MAP['tags'], MAP['formats']] for x in self.tag_browser_categories.get_custom_fields(): if self.tag_browser_categories[x]['is_multiple']: diff --git a/src/calibre/library/tag_categories.py b/src/calibre/library/tag_categories.py index 41477acba8..63327fac45 100644 --- a/src/calibre/library/tag_categories.py +++ b/src/calibre/library/tag_categories.py @@ -36,7 +36,7 @@ class TagsMetadata(dict, DictMixin): 'kind':'standard', 'name':_('Authors'), 'search_labels':['authors', 'author']}), ('series', {'table':'series', 'column':'name', - 'datatype':None, 'is_multiple':False, + 'datatype':'text', 'is_multiple':False, 'kind':'standard', 'name':_('Series'), 'search_labels':['series']}), ('formats', {'table':None, 'column':None, @@ -60,30 +60,34 @@ class TagsMetadata(dict, DictMixin): 'kind':'standard', 'name':_('Tags'), 'search_labels':['tags', 'tag']}), ('comments', {'table':None, 'column':None, - 'datatype':None, 'is_multiple':False, + 'datatype':'text', 'is_multiple':False, 'kind':'not_cat', 'name':None, 'search_labels':['comments', 'comment']}), ('cover', {'table':None, 'column':None, 'datatype':None, 'is_multiple':False, 'kind':'not_cat', 'name':None, 'search_labels':['cover']}), + ('timestamp', {'table':None, 'column':None, + 'datatype':'datetime', 'is_multiple':False, + 'kind':'not_cat', 'name':None, + 'search_labels':['date']}), ('isbn', {'table':None, 'column':None, - 'datatype':None, 'is_multiple':False, + 'datatype':'text', 'is_multiple':False, 'kind':'not_cat', 'name':None, 'search_labels':['isbn']}), ('pubdate', {'table':None, 'column':None, - 'datatype':None, 'is_multiple':False, + 'datatype':'datetime', 'is_multiple':False, 'kind':'not_cat', 'name':None, 'search_labels':['pubdate']}), ('title', {'table':None, 'column':None, - 'datatype':None, 'is_multiple':False, + 'datatype':'text', 'is_multiple':False, 'kind':'not_cat', 'name':None, 'search_labels':['title']}), ] # search labels that are not db columns search_items = [ 'all', - 'date', +# 'date', 'search', ]