Closed artgoldberg closed 4 years ago
I have made the error message more informative.
Essentially, this error is the manifestation of the principle of least astonishment.
This error is related to OneToOneAttribute
s. Their values cannot be directly changed to other non-None
values because doing so could cause opaque side effects to the reverse relationship of the related object, which could confuse users because its not something they would likely anticipate. To change their value, the value should first be set to None
. Then the value can be changed to another non-None
value. wc_lang/tests/test_core.py:test_non_unique_error_message
and obj_tables/tests/test_core.py:test_onetooneattribute
illustrate how this is intended to work.
Strictly speaking, its not necessary to throw an error in this scenario. Another potential way to navigate this issue would be to provide another method with a name like safe_set_value
. The downside would be that most users would likely use the default method when they should generally use the safe method.
safe_set_value
method: does the error checking discussed above. this ensures that there are no opaque side effects.