Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: prevent wrong formatting float values by locale #121

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

Closed
gpedro wants to merge 3 commits into grimzy:master from gpedro:fix/locale

Conversation

@gpedro
Copy link

@gpedro gpedro commented Mar 3, 2020
edited
Loading

resolves #84
that's the right-way fix. but to avoid install ext-intl, we can just replace comma by a dot.

Copy link
Owner

grimzy commented Mar 3, 2020

Looks good and tests are passing on my machine. Any idea why they're failing on Travis: https://travis-ci.org/grimzy/laravel-mysql-spatial/builds/657630242 ?

Copy link
Author

gpedro commented Mar 3, 2020

i have changed MAX_FRACTION_DIGITS from -1 to 12. reason to choose twelve:

Captura de Tela 2020年03月03日 às 07 20 31

Copy link
Author

gpedro commented Mar 3, 2020
edited
Loading

Copy link
Owner

grimzy commented Mar 6, 2020

I've delayed merging this PR because adding ext-intl would most likely break builds if I release a minor. I also want to avoid releasing a major and replacing a comma felt like a quick-fix (i18n-wise).

I'm going to test this out real quick: https://github.com/symfony/polyfill-intl-icu. It's already loaded when you build Laravel. This package adds ext-intl in composer's suggest and will use the PHP extension if it's already installed on the server.

gpedro reacted with thumbs up emoji

Copy link
Owner

grimzy commented Mar 6, 2020
edited
Loading

Thanks for fixing the tests.
I'm wondering if we're losing accuracy. Easy to test.
In any case, it doesn't seem that PHP compares floats past the 11th decimal either: https://github.com/grimzy/laravel-mysql-spatial/blob/2.2.0/tests/Integration/SpatialTest.php#L351 so we should be safe with 12 numbers after the decimal separator.

Copy link
Owner

grimzy commented Mar 6, 2020
edited
Loading

With symfony/polyfill-intl-icu: https://github.com/grimzy/laravel-mysql-spatial/tree/fix/locale-polyfill

Edit: easier to see the changes in a PR: #126

Copy link

@grimzy This week I came across a MySQL error "Invalid GIS data provided" and ultimately tracked it down to my locale rendering floats with a comma when converted to strings. Then I just saw this issue, where the bug was presumably fixed. I am on version 4.0.0.

Is the fix still pending merge? Or is this a new issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@f0ntana f0ntana f0ntana approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Invalid parameter value: 3037 Invalid GIS data provided to function st_geometryfromtext.

AltStyle によって変換されたページ (->オリジナル) /