From 5d02ab17cda6854d17933d0eff5a835ad2ea99ea Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Wed, 11 Dec 2024 18:36:46 +0000 Subject: [PATCH] fix: Numbers such as 1e100 cannot be retrieved from DynamoDB (#4916) --- api/environments/dynamodb/wrappers/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/environments/dynamodb/wrappers/base.py b/api/environments/dynamodb/wrappers/base.py index 5f0d545be422..9358ee62d4bd 100644 --- a/api/environments/dynamodb/wrappers/base.py +++ b/api/environments/dynamodb/wrappers/base.py @@ -1,13 +1,20 @@ import typing +from decimal import Context from functools import partial import boto3 +import boto3.dynamodb.types from botocore.config import Config if typing.TYPE_CHECKING: from mypy_boto3_dynamodb.service_resource import Table +# Avoid `decimal.Rounded` when reading large numbers +# See https://github.com/boto/boto3/issues/2500 +boto3.dynamodb.types.DYNAMODB_CONTEXT = Context(prec=100) + + class BaseDynamoWrapper: table_name: str = None