mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-17 11:32:22 +03:00
Merge 9b0aa5d0cd
into 8290326308
This commit is contained in:
commit
1582da5428
|
@ -28,6 +28,8 @@ class Decimal(Scalar):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_value(value):
|
def parse_value(value):
|
||||||
|
if value == "":
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
return _Decimal(value)
|
return _Decimal(value)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -66,3 +66,10 @@ def test_decimal_string_query_integer():
|
||||||
assert not result.errors
|
assert not result.errors
|
||||||
assert result.data == {"decimal": str(decimal_value)}
|
assert result.data == {"decimal": str(decimal_value)}
|
||||||
assert decimal.Decimal(result.data["decimal"]) == decimal_value
|
assert decimal.Decimal(result.data["decimal"]) == decimal_value
|
||||||
|
|
||||||
|
def test_parse_decimal_empty_string():
|
||||||
|
"""Parsing an empty string should return None"""
|
||||||
|
result = schema.execute("""{ decimal(input: \"\") }""")
|
||||||
|
assert not result.errors
|
||||||
|
assert result.data == {"decimal": None}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user