8000 Bigint coerce to string missing · Issue #9733 · encode/django-rest-framework · GitHub
[go: up one dir, main page]

Skip to content
Bigint coerce to string missing #9733
Open
@HoodyH

Description

@HoodyH

I've found this setting but there is no counterpart for Bigint

COERCE_DECIMAL_TO_STRING

JSON does not have a native BigInt type — it is safely precise for integers only up to 2⁵³ − 1 (i.e. 9,007,199,254,740,991). Beyond this threshold, numbers lose precision and may be silently truncated or rounded when parsed in JavaScript or other languages.

It depends on the json library implementation, this particular issue doesn’t happen in Python but it’s not consistent across all languages JSON libraries

Why DRF test frontend works?
Because it uses FormData, basically it is all string data, and since the server side render is handled by python no bigint errors occour

Resources:
Conversion problems

Since javascript is a lot used, this is an issue that have to be addressed in my opinion, i know that the bigint problem with ids will happen only at very large scale and probably a lot of people will never encounter this, but if we find a solution it would be wonderfull.

COERCE_BIGINT_TO_STRING

I suggest to add a flag like this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0