#36425: Clarify backend-specific mappings and portable safe ranges of
PositiveIntegerField types
-------------------------------------+-------------------------------------
Reporter: Jeff Cho | Type:
| Cleanup/optimization
Status: new | Component:
| Documentation
Version: 5.1 | Severity: Normal
Keywords: docs, mysql, orm, | Triage Stage:
fields | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Currently, the documentation for PositiveSmallIntegerField,
PositiveIntegerField, and PositiveBigIntegerField mentions only a "safe
range" of values. However, it doesn't explain why these ranges were
chosen, nor what actual database column types these fields map to.
For example, in MySQL, these fields map to UNSIGNED types (UNSIGNED INT,
BIGINT, SMALLINT), and can accept much larger values than the "safe
range". This mapping is not mentioned anywhere in the documentation.
As a result, users must inspect the Django source code or rely on third-
party discussions to understand what these fields actually do in
production.
This patch proposes to:
- Clearly define "safe range" as the portable, cross-backend-compatible
range
- Explicitly mention that actual DB column types vary by backend
- Add MySQL-specific notes stating these fields map to UNSIGNED
INT/BIGINT/SMALLINT
See common user confusion:
-
https://stackoverflow.com/questions/18925760/unsigned-integer-field-in-
django
-
https://stackoverflow.com/questions/18513350/can-i-have-an-unsigned-
autofield
-
https://stackoverflow.com/questions/73027108/django-
positivebigintegerfield
--
Ticket URL: <
https://code.djangoproject.com/ticket/36425>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.