You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If the beanie DecimalAnnotation is used with a model class, then the Decimal
values are written out as numbers and read in as floats when serializing to json.
But if only Decimal is used, which is supported by Pydantic, then the value is written out in json as String and imported again as Decimal.
The DecimalAnnotaton should behave like the Decimal type when serializing.
Additional context
In the DecimalCustomAnnotation class the float_schema is used. Is there a specific reason for this?
If core_schema.decimal_schema() is used here then DecimalAnnotation behaves like the Decimal type when serializing / deserializing.
Describe the bug
If the beanie DecimalAnnotation is used with a model class, then the Decimal
values are written out as numbers and read in as floats when serializing to json.
But if only Decimal is used, which is supported by Pydantic, then the value is written out in json as String and imported again as Decimal.
To Reproduce
Case 1 - DecimalAnnotation
Console output:
Case 2 - Decimal
Console output:
Expected behavior
The DecimalAnnotaton should behave like the Decimal type when serializing.
Additional context
In the DecimalCustomAnnotation class the float_schema is used. Is there a specific reason for this?
If core_schema.decimal_schema() is used here then DecimalAnnotation behaves like the Decimal type when serializing / deserializing.
The text was updated successfully, but these errors were encountered: