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

Decimals, #106

Closed
dirkjf opened this issue Oct 15, 2019 · 8 comments
Closed

Decimals, #106

dirkjf opened this issue Oct 15, 2019 · 8 comments

Comments

@dirkjf
Copy link
Contributor

dirkjf commented Oct 15, 2019

When I have any decimal type in my entity, upon updating the entity a new audit record is saved in which it seems the value was changed. This is even the case when I set the scale in my form to 1. For example, if I have a number saved as 5.0 in my database, when I edit the entity and do not touch this number, for this value "{"old":"5.0","new":"5"}" is saved.

I am using MariaDB version 10.3.15 on an Apache server 2.4.39 with PHP 7.3.6.

My entity field looks like this:

/**
* @ORM\Column(type="decimal", precision=3, scale=1, nullable=true)
*/
private $credits;

Thanks!

@DamienHarper
Copy link
Owner

@dirkjf thanks for the report. I’ll have a look at it asap.

@DamienHarper
Copy link
Owner

@dirkjf Could you please test again master branch and provide me some feedback?

@dirkjf
Copy link
Contributor Author

dirkjf commented Oct 18, 2019

Tested it again, but I still have the same issue. Every time I update for all decimal values: {"old":"5.0","new":5}. And although it may show only "5" in the form, the actual data that is stored is "5.0".

@dirkjf
Copy link
Contributor Author

dirkjf commented Oct 18, 2019

BTW, also when in my form I type "5.0", I get the same {"old":"5.0","new":5}.

@dirkjf
Copy link
Contributor Author

dirkjf commented Oct 18, 2019

I ran some more tests. What helps (FOR ME) is to type cast the value to a float. So when I use on line 160 of AuditHelper.php: $convertedValue = (float) $type->convertToPHPValue($value, $platform); it works as I would expect. I don't know if this could be problematic for other users.

@DamienHarper
Copy link
Owner

DamienHarper commented Oct 18, 2019

@dirkjf ok but what bothers me is that on master, decimals are process as you describe (since my last changes): https://github.com/DamienHarper/DoctrineAuditBundle/blob/2c7a399215be787937fb3c2486ebf969031312b3/src/DoctrineAuditBundle/Helper/AuditHelper.php#L157

@dirkjf
Copy link
Contributor Author

dirkjf commented Oct 18, 2019

I understand. Maybe this is why?

@DamienHarper
Copy link
Owner

I close this issue as this is more a Doctrine one.

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

No branches or pull requests

2 participants