Opened 10 years ago
Closed 10 years ago
#23377 closed Bug (duplicate)
models.PositiveIntegerField does not perform proper validation in model.full_clean()
Reported by: | Patryk Zawadzki | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.6 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
You can assign any negative value and call instance.full_clean()
and everything will pass until at the very end you get a nasty IntegrityError
from your database backend—at which point you can only roll back the transaction.
Change History (3)
comment:1 by , 10 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 10 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Looking into this, it turns out that the difference of behavior between sqlite and postgres was indeed a feature.
The issue you're reporting is a duplicate of #12030 which was fixed in 1506c71a95cd7f58fbc6363edf2ef742c58d2487 and will be part of the upcoming 1.7 release.
Thanks.
Hi,
This seems to be database-dependent. With sqlite, no validation error is raised but when using postgresql, I get
ValidationError: {'foo': ['Ensure this value is greater than or equal to 0.']}
.I'm not sure if that's a bug or the intended behavior but I'll err on the side of the former and mark this ticket as accepted.
Thanks.