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

SQL type FLOAT should not be used for economical data #15994

Merged
merged 9 commits into from Jun 2, 2020
Merged

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented May 27, 2020

fix #12575

Similar to #15408 not using DECIMAL as it would change the output like this: https://travis-ci.org/github/matomo-org/matomo/jobs/691567334#L714-L742 . Tested this in 025410d

Instead using double which should at least not round the big numbers like it used to in #14934 (comment)

Just like in #15408 only doing this for new installs.

For existing installs created this FAQ https://matomo.org/faq/how-to/how-do-i-fix-a-truncated-or-rounded-revenue-or-price-value/

For the log_conversion.revenue* dimensions I could change the type directly in the dimension as it would have caused an update for existing users. I therefore moved it directly to the MySQL schema so it's good for new installs but doesn't affect existing users. Since the plugin cannot be uninstalled I can't think of a benefit of having it in the dimension directly.

@tsteur tsteur added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label May 27, 2020
@tsteur tsteur added this to the 4.0.0 milestone May 27, 2020
@tsteur tsteur added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label May 27, 2020
@tsteur tsteur added Needs Review PRs that need a code review and removed Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. labels May 27, 2020
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we maybe could update those columns for existing installs, if they actually weren't in use. If there are only NULL values in the database we could update safely I guess.

@tsteur
Copy link
Member Author

tsteur commented May 27, 2020

@sgiehl not sure it's worth it? Most installs might already have a value set in case they use the feature and even if we could migrate it, not too many people will run into this issue? Would avoid several full table scans on this columns.

@sgiehl
Copy link
Member

sgiehl commented May 28, 2020

Was just a thought. Btw. do we need to add those columns to an (old) update script? If someone updates from an very old version, where those columns didn't exist yet, the updater won't do that automatically anymore, as the dimensions don't trigger that anymore. 🤔

@tsteur
Copy link
Member Author

tsteur commented May 28, 2020

Good point @sgiehl . Didn't think of this. Added logic for this. Tested it locally when all columns were present and when some were missing. Worked for me.

@tsteur tsteur merged commit 2d61f4b into 4.x-dev Jun 2, 2020
@tsteur tsteur deleted the m12575 branch June 2, 2020 20:15
@robocoder
Copy link
Contributor

I thought #12575 was because float can't represent exact decimal numbers. Wouldn't that still be an issue with double?

https://dev.mysql.com/doc/refman/5.7/en/fixed-point-types.html

@tsteur
Copy link
Member Author

tsteur commented Jun 2, 2020

Hi @robocoder yes it would be still an issue indeed. Ideally would use decimal. The problem was it changes the output in some reports like instead of 5.23 it was returning 5.2300 eg if it is like decimal(16,4). We could obviously work around this in PHP but figured the benefit of decimal might not be worth it? Haven't tested how segments would behave. Eg whether a segment value of 5.23 would also match 5.2300 etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL type FLOAT should not be used for economical data
3 participants