Opened 11 years ago
Closed 11 years ago
#23377 closed Bug (duplicate)
models.PositiveIntegerField does not perform proper validation in model.full_clean()
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 , 11 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 11 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.