New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Country implements ordering #361
Conversation
Country needs to be orderable if it is part of the primary key and cascade deletion is in use.
This needs at least couple of unit tests. Also why not use total_ordering decorator from functools module? |
I'll try to prepare some tests. Regarding the use of tolta_ordering, if you want, I can use it. I did not just because of the note at total_ordering, and because it was easy to implemente the four methods
Probably performance will never be an issue, but every little bit helps. |
I'm all for code clarity and simplicity over micro-optimizations, hence please use total_ordering even if there is a small performance penalty (as there is with any decorators). For tests you can just have single test method parametrized @pytest.mark.parametrize(
'assertion',
[
Country('FI') > Country('ES'),
...
]
)
def test_ordering(assertion):
assert assertion |
I have implemented the changes that you propose. Please check. |
Country
implements a total ordering based onCountry.code
. This ordering is also comparable to any string. This solves #360