Skip to content
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

Incorrectly detecting change of zeroes in decimal place #260

Open
Liamhanninen opened this issue Sep 2, 2020 · 2 comments · May be fixed by #261
Open

Incorrectly detecting change of zeroes in decimal place #260

Liamhanninen opened this issue Sep 2, 2020 · 2 comments · May be fixed by #261

Comments

@Liamhanninen
Copy link

First of all this library has been so useful. It's exactly what I needed and works really well. There is only one issue.
It seems to be detecting changes that aren't occurring. At first I thought the model was adding zeros or the db was removing them. But after some digging I think it's a bug with django-auditlog.
It thinks a change occurred anytime I save this record: it thinks that I started with .00 and changed it to .0. But .00 is the existing value and I didn't change anything. I just saved() the record.
image
I checked the output of the form itself in the clean() method:

services_sub_total
44.00
sum_payments
33.00

And then in the database:
image
I just cant figure out where/why this is detecting only one zero in the decimal place - I'm not seeing that .0 anywhere.
Could the delta functions be truncating multiple zeros in the decimals to .0?

@iklinac
Copy link

iklinac commented Sep 2, 2020

As already responded to SO question

If you look up into source you would see that it compares these two values not as field values but through use of smart_text values are converted to string inside get_field_value

So it basically compares "44.00" and your value of "44.0" and this is different string so it is triggered as change

Not sure if this is by design as in my eyes would be considered bug

@Liamhanninen
Copy link
Author

Thanks for digging into that and providing the file and line! I will hack it for now. Hopefully it is fixed here (I'm sure my way will not be the best).

Liamhanninen added a commit to Liamhanninen/django-auditlog that referenced this issue Sep 6, 2020
Liamhanninen added a commit to Liamhanninen/django-auditlog that referenced this issue Sep 6, 2020
@Linkid Linkid linked a pull request Mar 1, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants