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

enhancing robustness of int/float castings for string values containing commas #3412

Open
2 of 3 tasks
Speedy1991 opened this issue Mar 19, 2024 · 0 comments
Open
2 of 3 tasks

Comments

@Speedy1991
Copy link
Contributor

Speedy1991 commented Mar 19, 2024

I run into this problem again and again and it is always annoying to fix it

Feature Request Type

  • Core functionality
  • Alteration (enhancement/optimization) of existing feature(s)
  • New behavior

Description

ValueError: could not convert string to float: '3,3'
  File "graphql/type/scalars.py", line 123, in serialize_float
    num = output_value if isinstance(output_value, float) else float(output_value

Currently values with , will break int/float resolvers, but most times this is not a real error.

It would be awesome if we can handle , like . if the value is a string like this:

output_value = output_value.replace(',', '.').strip() if isinstance(output_value, str) else output_value
num = output_value if isinstance(output_value, float) else float(output_value)

The same happens with integers

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
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

1 participant