IntegerField could validate too large numbers to work with PostgreSQL and MySQL be default
|Reported by:||Petr Marhoun <petr.marhoun@…>||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Be default (without some additional validation) integer fields in Django do not checks any intervals for inserted numbers. So for example, if someone try official tutorial from Django documentation and use recommended database (PostgreSQL), he can get uncatched exception ("DatabaseError: integer out of range"). It would be nice to validate this range - it is problem not only for PostgreSQL but also for MySQL (but I do not know if these two databases are so important that they should define interval common for all databases).
BigIntegerField in Django checks interval [2 63, 2 63 - 1] so for consistency IntegerField could check interval [2 31, 2 31 -1]. Also, for other main fields (for example char fields or float fields or decimal fields or date fields) it is quite difficult or impossible to get uncatched exceptions - but it is really easy for integer fields.
I prepare patch with two tests - one (for BigIntegerField) passes on all tested databases (PostgreSQL 8.4.8, MySQL 5.1.54 with InnoDB, SQlite from Python 2.7.1 - everything on Ubuntu 11.04 64bit). The almost same second one (for IntegerField) failes on PostgreSQL with "DatabaseError: integer out of range" and on MySQL with "AssertionError" (saved number is truncated).