mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Proper fix for unicode sorting error
This commit is contained in:
parent
4f5764b1a8
commit
dcedc5b87d
@ -31,7 +31,7 @@ class Field(object):
|
|||||||
self.has_text_data = dt in {'text', 'comments', 'series', 'enumeration'}
|
self.has_text_data = dt in {'text', 'comments', 'series', 'enumeration'}
|
||||||
self.table_type = self.table.table_type
|
self.table_type = self.table.table_type
|
||||||
self._sort_key = (sort_key if dt in ('text', 'series', 'enumeration') else lambda x: x)
|
self._sort_key = (sort_key if dt in ('text', 'series', 'enumeration') else lambda x: x)
|
||||||
self._default_sort_key = ''
|
self._default_sort_key = b''
|
||||||
if dt in {'int', 'float', 'rating'}:
|
if dt in {'int', 'float', 'rating'}:
|
||||||
self._default_sort_key = 0
|
self._default_sort_key = 0
|
||||||
elif dt == 'bool':
|
elif dt == 'bool':
|
||||||
|
@ -52,16 +52,10 @@ class Table(object):
|
|||||||
self.name, self.metadata = name, metadata
|
self.name, self.metadata = name, metadata
|
||||||
self.sort_alpha = metadata.get('is_multiple', False) and metadata.get('display', {}).get('sort_alpha', False)
|
self.sort_alpha = metadata.get('is_multiple', False) and metadata.get('display', {}).get('sort_alpha', False)
|
||||||
|
|
||||||
text = lambda x:x.decode('utf-8', 'replace') if isinstance(x, bytes) else x
|
|
||||||
|
|
||||||
# self.unserialize() maps values from the db to python objects
|
# self.unserialize() maps values from the db to python objects
|
||||||
self.unserialize = \
|
self.unserialize = \
|
||||||
{
|
{
|
||||||
'datetime': _c_convert_timestamp,
|
'datetime': _c_convert_timestamp,
|
||||||
'text': text,
|
|
||||||
'comments': text,
|
|
||||||
'series': text,
|
|
||||||
'enumeration': text,
|
|
||||||
'bool': bool
|
'bool': bool
|
||||||
}.get(
|
}.get(
|
||||||
metadata['datatype'], lambda x: x)
|
metadata['datatype'], lambda x: x)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user