Opened 10 years ago
Closed 10 years ago
#23357 closed Bug (fixed)
MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is wrong type
Reported by: | Jon Dufresne | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | introspection |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The MySQL backend maps a database field of type FIELD_TYPE.SHORT
to IntegerField
, but it seems to me that it should map to SmallIntegerField
. The SmallIntegerField
field class produces a smallint
which eventually ends up as data type FIELD_TYPE.SHORT
.
This can be found in file django/db/backends/mysql/introspection.py
, class attribute DatabaseIntrospection.data_types_reverse[FIELD_TYPE.SHORT]
.
Contrast this with the file django/db/backends/mysql/creation.py
, class attribute DatabaseCreation.data_types['SmallIntegerField']
.
Change History (10)
comment:1 by , 10 years ago
Cc: | added |
---|---|
Component: | Uncategorized → Database layer (models, ORM) |
Easy pickings: | set |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
follow-up: 3 comment:2 by , 10 years ago
Cc: | removed |
---|---|
Keywords: | introspection added |
Is #22738 related?
comment:3 by , 10 years ago
comment:4 by , 10 years ago
I'd be happy to create and submit a patch that corrects the FIELD_TYPE.SHORT
, but I'm not sure what should be done about FIELD_TYPE.TINY
as that could theoretically represent either an int
(of limited size) or a bool
.
comment:5 by , 10 years ago
Pull request to handle SHORT
: <https://github.com/django/django/pull/3117>
comment:6 by , 10 years ago
I updated the patch with the requested unit tests. I tested the unit tests using MySQL and sqlite. I do not have other database backends readily available to me.
Please let me know if there are any additional comments, suggestions, or concerns. Thanks.
comment:7 by , 10 years ago
Easy pickings: | unset |
---|---|
Has patch: | set |
Patch needs improvement: | set |
This will require additional test adjustment and special casing for Oracle. Left comments on the PR.
comment:8 by , 10 years ago
This will require additional test adjustment and special casing for Oracle. Left comments on the PR.
Thanks for the comments. I updated the patch based on the feedback.
comment:9 by , 10 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:10 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Yes, and the same for
FIELD_TYPE.TINY
.