mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
py3: Fix sorting on one-one fields that can have None values
Fixes #1878388 [Private bug](https://bugs.launchpad.net/calibre/+bug/1878388)
This commit is contained in:
parent
e40834080e
commit
9c05bb0ff3
@ -192,6 +192,13 @@ class OneToOneField(Field):
|
||||
dk = self._default_sort_key
|
||||
sk = self._sort_key
|
||||
if sk is IDENTITY:
|
||||
if dk is not None:
|
||||
def none_safe_key(book_id):
|
||||
ans = bcmg(book_id, dk)
|
||||
if ans is None:
|
||||
ans = dk
|
||||
return ans
|
||||
return none_safe_key
|
||||
return lambda book_id:bcmg(book_id, dk)
|
||||
return lambda book_id:sk(bcmg(book_id, dk))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user