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

[FIX] Decimal scalar inaccurate conversion of float to decimal #1594

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mak626
Copy link

@mak626 mak626 commented Feb 10, 2025

Fixes #1593

Example:-
Decimal(0.01) created a value Decimal("0.01000000000000000020816681711721685132943093776702880859375")

Additional:
The Decimal field now accepts string, int & float. Previously, it was just string & int

… values

Example:-
Decimal(0.01) -> Decimal("0.01000000000000000020816681711721685132943093776702880859375")

Additional:
Decimal field now accepts string, int & float. Previously it was just string & int
@mak626 mak626 changed the title fix Decimal scalar inaccurate conversion of float -> decimal conversions [FIX] Decimal scalar inaccurate conversion of float to decimal Feb 10, 2025
return cls.parse_value(node.value)
return Undefined

@staticmethod
def parse_value(value):
try:
return _Decimal(value)
return _Decimal(str(value))
Copy link
Author

Choose a reason for hiding this comment

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

Using the same implementation as done at Strawberry

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

Successfully merging this pull request may close these issues.

Inaccurate Float-to-Decimal Conversion in parse_value of Decimal Scalar
1 participant