Validate that IntegerField is a valid Signed value for databases that don't do it themselves.
|Reported by:||Cal Leeming||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
So I found that, if you attempt to store a number larger than the SIGNED INT maximum, for some reason, Django (or the db) auto converts it to the maximum allowed, rather than throwing an error. This really causes some strange issues, especially when your app logic *thinks* you've managed to save the correct value lol.
Suggested patch might be, enforcing a default maximum, which throws a ValueError whenever you try saving it into the database??
If this would be an appropriate way forward, I'd be more than happy to submit a patch.
PS) To test for yourself, try using the following:
class TestModel(models.Model): test_field = models.IntegerField(db_index = True) TestModel( test_field = 3517601254 ) TestModel.objects.get(test_field = 3517601254)
Change History (17)
comment:7 Changed 6 years ago by
|Summary:||SIGNED IntegerField down converts to highest allowed number, instead of throwing an exception.. wtf? → Validate that IntegerField is a valid Signed value for databases that don't do it themselves.|
|Triage Stage:||Unreviewed → Design decision needed|
comment:15 Changed 6 years ago by
|Status:||closed → reopened|
|Version:||1.3 → SVN|