#24489: PositiveIntegerField accepting Negatives
-------------------------------------+-------------------------------------
Reporter: projectgoav | Owner: nobody
Type: Uncategorized | Status: closed
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: Models Fields | Triage Stage:
PositiveIntegerField | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by knbk):
* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0
Comment:
I'm marking this as invalid:
- Validation is not handled by the model, but rather by the database and
model forms. Model forms enforce the minimal value.
- The documentation makes no claims on which values are not supported,
only on which values are guaranteed to be supported. Other than that, it
is backend-dependant. SQLite does not enforce any restrictions, but most
other backends do.
- The value on a model is never changed by saving it, so `post.views` will
always be `-10` instead of the actual database value. For MySQL and
probably other backends, the value is correctly set to `0` when reloaded
from the database.
So while it might be semantically incorrect to support negative values,
it's not a bug, and changing it would be backwards-incompatible. Feel free
to add a note to the documentation, though.
--
Ticket URL: <https://code.djangoproject.com/ticket/24489#comment:1>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/069.dec5789b0cfc3952d06180f3594bbfbd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.