Opened 13 years ago
Closed 10 years ago
#18255 closed Bug (fixed)
Inconsistent data type for BigIntegerField after calling full_clean()
Reported by: | anonymous | Owned by: | Adam Duren |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Areski Belaid | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Example:
class MyModel(Model): big = BigIntegerField() def full_clean(self): print type(self.big) super(MyModel, self).full_clean() print type(self.big)
When saving the model I get:
<type 'long'> <type 'int'>
This means that full_clean() somehow converts the long to int. On the other hand, when getting the model from the database (MySQL in my case), the output of type(my_model.big) will be long again. From a user point of view this behavior is inconsistent and confusing.
Change History (10)
comment:1 by , 13 years ago
Version: | 1.3 → 1.4 |
---|
comment:3 by , 13 years ago
Use case: In my particular environment we have to check for data types in a custom clean() method in every model. Example code:
my_m = MyModel() my_m.big = 2L my_m.save() my_m2 = MyModel() my_m2.big = my_m.big my_m2.save() #raises ValidationError, because an integer was provided
On the other hand tis code works without a validation error:
my_m = MyModel.objects.get(id=1) my_m2 = MyModel() my_m2.big = my_m.big my_m2.save()
comment:4 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 12 years ago
Has patch: | set |
---|
Fixed and tests written, pull request https://github.com/django/django/pull/810
comment:7 by , 12 years ago
Patch needs improvement: | set |
---|
The patch doesn't account for Python 3 (where long
type doesn't exist).
comment:8 by , 11 years ago
I made the changes in pull request https://github.com/django/django/pull/2202 as requested in pull request https://github.com/django/django/pull/810.
comment:9 by , 10 years ago
Cc: | added |
---|
This is already fixed on master, do we want to fix it on 1.4 or simply mark this ticket as wontfix?
comment:10 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Per our supported versions policy, 1.4 is only receiving security fixes so we can close this. Thank-you for triaging.
Also applies to Django 1.4