Opened 9 years ago

Closed 9 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


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 Changed 9 years ago by Baptiste Mispelon

Component: UncategorizedDatabase layer (models, ORM)
Triage Stage: UnreviewedAccepted


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.


comment:2 Changed 9 years ago by Patryk Zawadzki

I am getting an IntegrityError with Django 1.6.6 and psycopg2.

comment:3 Changed 9 years ago by Baptiste Mispelon

Resolution: duplicate
Status: newclosed

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.


Note: See TracTickets for help on using tickets.
Back to Top