Internally inconsistent documentation of `get` and `first` w.r.t. behaviour on multiple resulting rows
Opened this issue · 1 comments
Describe the bug
The docstring both mentions that the first row meeting the criteria is returned, and that MultipleMatches
exception is raised if more than 1 row is returned.
To Reproduce
Read the following docstrings:
ormar/ormar/queryset/queryset.py
Lines 892 to 897 in 6e6eafa
ormar/ormar/queryset/queryset.py
Lines 948 to 958 in 6e6eafa
ormar/ormar/relations/querysetproxy.py
Lines 387 to 401 in 6e6eafa
Expected behavior
The docstring:
- either says that the first row meeting the criteria is returned (and doesn't have any mention of raising a
MultipleMatches
exception) - or it says that the a single row meeting the criteria is returned (and doesn't have any mention of ordering).
Versions (please complete the following information):
ormar: 6e6eafa
Well it behaves differently depending if you pass any filters or not.
When called empty (get() or
first()`) it returns last/first row ordered by pk.
If you set a filter it returns one row matching the criteria or raises an Exception if multiple rows match the criteria.
So both of them return at max one record.
So that should probably be clarified in docstrings but both are correct (but not full).
If you could issue a PR for this I would be grateful.