Properly track falsy instances in RelationCounterField.
Review Request #9749 — Created March 6, 2018 and submitted — Latest diff uploaded
RelationCounterField
(and parts ofCounterField
) were testing
instances for truthiness to see if they were valid (i.e., references
haven't dropped), but if an instance defined__nonzero__
or__len__
(with a result of 0), the checks would fail and state would be lost.These checks have changed to explicitly check against
None
, ensuring
that we don't accidentally lose anything in these cases, and to add
validity checks in places where they were missing.While here, I also got rid of a method that was defined that was never
used. It was also assuming validity, and rather than fix it, it was
worth just getting rid of the function.
Unit tests pass. They failed with the addition of a
__nonzero__
function in the models prior to these fixes.