Skip to content

_to_entity_int32 is not appropriate for Python integers #35554

Open
@minerjaime

Description

@minerjaime

I have a use case where I'd like to use Python integer values within my Cosmos DB table. When the integer values exceed the size allotted to an EdmType.INT32, I receive errors.

Since Python isn't bound to the same size limitations for its integers, can we get a more appropriate "_to_entity" function for handling Python ints?

I would propose this:
def _to_entity_int(value):
int_value = int(value)
if int_value >= 2**63 or int_value < -(2**63):
raise TypeError(_ERROR_VALUE_TOO_LARGE.format(str(int_value), EdmType.INT64))
if int_value >= 2**31 or int_value < -(2**31):
return EdmType.INT64, str(value)
else:
return None, value

Thank you so much!

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.Tablescustomer-reportedIssues that are reported by GitHub users external to the Azure organization.feature-requestThis issue requires a new behavior in the product in order be resolved.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions