-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Huge DECIMAL number casted to FLOAT/DOUBLE #13151
Comments
Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues |
@sergeyklay @niden this shouldn't be closed as it is still a valid issue. As PHP does not support decimals natively, DECIMAL columns should be casted to STRING. Casting to double/float introduces a fresh hell of imprecisions. Saving longitude ( All in all, MySQL's |
Thanks @scrnjakovic This needs a bit more discussion actually on how we can address this. Decimal should be a double. However in the example above, keeping it as double will not help. I am wondering if this can be a user initiated change i.e. where the column is defined as string/varchar. |
Thanks @niden for reopening this :)
I would have to disagree with this. Unlike float and double, decimal has fixed precision. PHP
MySQL
MySQL
From this it's very clear that column with |
I see your point @scrnjakovic. I have no problem switching this to a bind type of string which will not force I think that we can get away with doing this provided that it is crystal clear in the documentation that if one uses decimal they should expect a string. |
Addressed in #13562 |
Expected and Actual Behavior
Analysis
As far as I could I've traced this cast to this code:
cphalcon/phalcon/db/adapter/pdo.zep
Line 242 in 107b6f0
Solution
I've extended the \Phalcon\Db\Adapter\Pdo\Mysql class and modified this a bit like this:
This does solve my problem, but I guess it could be solved some other way?
Details
php --ri phalcon
)php -v
)The text was updated successfully, but these errors were encountered: