#34370: PositiveIntegerField validators don't work if the database is SQLite,
leading to overflow errors
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
alexurbanowicz |
Type: Bug | Status: new
Component: Database | Version: 4.1
layer (models, ORM) | Keywords: IntegerField SQLite
Severity: Normal | MaxValueValidator
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
The [https://docs.djangoproject.com/en/4.1/ref/models/fields/#integerfield
documentation for IntegerField] states that:
''It uses MinValueValidator and MaxValueValidator to validate the input
based on the values that the default database supports.''
The
[https://docs.djangoproject.com/en/4.1/ref/models/fields/#positiveintegerfield
PositiveIntegerField] states that:
"Like an IntegerField, but must be either positive or zero (0). Values
from 0 to 2147483647 are safe in all databases supported by Django. The
value 0 is accepted for backward compatibility reasons."
So it is simple to assume that PositiveIntergerField uses
MaxValueValidator that applies the limit of the default database.
Yet it is possible, while using SQLite to attempt to store the value of
positive integer not supported by the DB, which leads to OverflowError:
**Python int too large to convert to SQLite INTEGER**
So it is either the IntegerField's MaxValueValidator is not applied,
contrary to what the documentation suggests, or the documentation has an
error for lack of specifying that you must use an explicit validator to
validate to the safe value given (why not default then?).
In my opinion it should be limited to the safe value by default, or have
the MaxValueValidator check it by default against the database limit.
Should I prepare the patch to limit it to the safe value?
This is also related to #27397.
--
Ticket URL: <https://code.djangoproject.com/ticket/34370>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701868458ce43-be060548-8f3a-48de-bf19-2da86d8f1196-000000%40eu-central-1.amazonses.com.