tortoise-orm
tortoise-orm copied to clipboard
QuerySetSingle behavior inconsistency
def get_or_none(self, *args: Q, **kwargs: Any) -> QuerySetSingle[Optional[MODEL]]:
"""
Fetch exactly one object matching the parameters.
"""
queryset = self.filter(*args, **kwargs)
queryset._limit = 2
queryset._single = True
return queryset # type: ignore
queryset._limit = 2 Why get_or_none uses limit 2? It is not an expected behavior.
Just noticed the same
Becase MultipleObjectsReturned detection
But you can use first instead