django-auditlog icon indicating copy to clipboard operation
django-auditlog copied to clipboard

Comparison of change of Decimal types is flaky, sometimes returns false positive

Open ses4j opened this issue 8 years ago • 0 comments

I was seeing false positives on my decimal fields, where I "changed the value" from .17000 to .17. Why does get_field_value stringify before comparing? I would think most datatypes will compare better if left as their real datatypes, no?

I added this in locally and it seemed happier:

    elif isinstance(field, (DecimalField, JSONField)):
        try:
            value = field.to_python(getattr(obj, field.name, None))
        except ObjectDoesNotExist:
            value = field.default if field.default is not NOT_PROVIDED else None

ses4j avatar Apr 10 '17 20:04 ses4j