-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Bigint coerce to string #9775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Bigint coerce to string #9775
Conversation
… can have string api representation
auvipy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
|
Any news? |
- typo fix - value test fix - import order fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new BigIntegerField serializer field to properly handle Django's BigIntegerField and BigAutoField model fields, addressing issue #9733. Previously, these fields were incorrectly mapped to the standard IntegerField serializer.
Key Changes:
- Introduces
BigIntegerFieldclass that extendsIntegerFieldwith optional string coercion for large integers - Adds
COERCE_BIGINT_TO_STRINGsetting (default:False) to control output format - Updates model field mappings to use
BigIntegerFieldforBigIntegerFieldandBigAutoField
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| rest_framework/fields.py | Implements new BigIntegerField class with coerce_to_string parameter and custom error messages |
| rest_framework/serializers.py | Imports BigIntegerField and updates serializer_field_mapping to map Django's BigIntegerField and BigAutoField to the new field type |
| rest_framework/settings.py | Adds COERCE_BIGINT_TO_STRING configuration setting with default value of False |
| docs/api-guide/fields.md | Documents the new BigIntegerField with its signature and parameters |
| docs/api-guide/settings.md | Documents the COERCE_BIGINT_TO_STRING setting and its behavior |
| tests/test_fields.py | Adds comprehensive test cases for BigIntegerField including validation, min/max constraints, and string coercion |
| tests/test_model_serializer.py | Updates expected serializer representation test to expect BigIntegerField instead of IntegerField |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fixing Bigint coerce to string missing
Creates a new type
BigIntegerFieldto mapdjango.models.BigIntegerFieldand solve the problemFix #9733