don't throw an error when an invalid sort order is provided

This commit is contained in:
Damien Elmes 2021-05-06 17:00:11 +10:00
parent be994f4102
commit 6ca089c36c

View File

@ -40,7 +40,7 @@ from anki.config import Config, ConfigManager
from anki.consts import * from anki.consts import *
from anki.dbproxy import DBProxy from anki.dbproxy import DBProxy
from anki.decks import Deck, DeckConfig, DeckConfigId, DeckId, DeckManager from anki.decks import Deck, DeckConfig, DeckConfigId, DeckId, DeckManager
from anki.errors import AbortSchemaModification, DBError, InvalidInput from anki.errors import AbortSchemaModification, DBError
from anki.lang import FormatTimeSpan from anki.lang import FormatTimeSpan
from anki.media import MediaManager, media_paths_from_col_path from anki.media import MediaManager, media_paths_from_col_path
from anki.models import ModelManager, Notetype, NotetypeDict, NotetypeId from anki.models import ModelManager, Notetype, NotetypeDict, NotetypeId
@ -579,7 +579,10 @@ class Collection:
return _pb.SortOrder( return _pb.SortOrder(
builtin=_pb.SortOrder.Builtin(column=order.key, reverse=reverse) builtin=_pb.SortOrder.Builtin(column=order.key, reverse=reverse)
) )
raise InvalidInput(f"{order} is not a valid sort order.")
# eg, user is ordering on an add-on field with the add-on not installed
print(f"{order} is not a valid sort order.")
return _pb.SortOrder(none=_pb.Empty())
def find_and_replace( def find_and_replace(
self, self,