[Django] #23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is wrong type

74 views
Skip to first unread message

Django

unread,
Aug 23, 2014, 8:27:36 PM8/23/14
to django-...@googlegroups.com
#23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is
wrong type
-------------------------------+--------------------
Reporter: jdufresne | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
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']`.

--
Ticket URL: <https://code.djangoproject.com/ticket/23357>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 24, 2014, 3:01:13 PM8/24/14
to django-...@googlegroups.com
#23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is
wrong type
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by claudep):

* cc: introspection (added)
* needs_better_patch: => 0
* component: Uncategorized => Database layer (models, ORM)
* needs_tests: => 0
* easy: 0 => 1
* needs_docs: => 0
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

Yes, and the same for `FIELD_TYPE.TINY`.

--
Ticket URL: <https://code.djangoproject.com/ticket/23357#comment:1>

Django

unread,
Aug 24, 2014, 4:36:07 PM8/24/14
to django-...@googlegroups.com
#23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is
wrong type
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: introspection | Needs documentation: 0

Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by shaib):

* cc: introspection (removed)
* keywords: => introspection


Comment:

Is #22738 related?

--
Ticket URL: <https://code.djangoproject.com/ticket/23357#comment:2>

Django

unread,
Aug 25, 2014, 6:03:58 AM8/25/14
to django-...@googlegroups.com
#23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is
wrong type
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: introspection | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by claudep):

Replying to [comment:2 shaib]:
> Is #22738 related?

Not really, as MySQL returns the same `type_code=1` for both TINYINT and
BOOLEAN. However, I just noticed that we might differentiate boolean
fields on MySQL with internal_size/precision (4 for TINYINT and 1 for
BOOLEAN).

--
Ticket URL: <https://code.djangoproject.com/ticket/23357#comment:3>

Django

unread,
Aug 26, 2014, 1:18:26 AM8/26/14
to django-...@googlegroups.com
#23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is
wrong type
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: introspection | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by jdufresne):

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`.

--
Ticket URL: <https://code.djangoproject.com/ticket/23357#comment:4>

Django

unread,
Aug 26, 2014, 1:27:16 AM8/26/14
to django-...@googlegroups.com
#23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is
wrong type
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: introspection | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by jdufresne):

Pull request to handle `SHORT`:
<https://github.com/django/django/pull/3117>

--
Ticket URL: <https://code.djangoproject.com/ticket/23357#comment:5>

Django

unread,
Aug 26, 2014, 5:51:51 PM8/26/14
to django-...@googlegroups.com
#23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is
wrong type
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: introspection | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by jdufresne):

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 addition comments, suggestions, or
concerns. Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/23357#comment:6>

Django

unread,
Aug 26, 2014, 7:22:28 PM8/26/14
to django-...@googlegroups.com
#23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is
wrong type
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: introspection | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by charettes):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* easy: 1 => 0


Comment:

This will require additional test adjustment and special casing for
Oracle. Left comments on the PR.

--
Ticket URL: <https://code.djangoproject.com/ticket/23357#comment:7>

Django

unread,
Aug 26, 2014, 11:40:03 PM8/26/14
to django-...@googlegroups.com
#23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is
wrong type
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: introspection | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by jdufresne):

> 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/23357#comment:8>

Django

unread,
Aug 27, 2014, 9:07:52 AM8/27/14
to django-...@googlegroups.com
#23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is
wrong type
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Ready for
Keywords: introspection | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by charettes):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/23357#comment:9>

Django

unread,
Aug 27, 2014, 10:59:37 AM8/27/14
to django-...@googlegroups.com
#23357: MySQL DatabaseIntrospection.data_types_reverse for FIELD_TYPE.SHORT is
wrong type
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) | Resolution: fixed

Severity: Normal | Triage Stage: Ready for
Keywords: introspection | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette <charette.s@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"f0d3dd4f04efa49e0b58da4847cb89770b59d4a8"]:
{{{
#!CommitTicketReference repository=""
revision="f0d3dd4f04efa49e0b58da4847cb89770b59d4a8"
Fixed #23357 -- Added small int introspection support to MySQL backend.

In the MySQL backend, updated the can_introspect_small_integer feature
flag to True. In data_types_reverse, map FIELD_TYPE.SHORT to a
SmallIntegerField. Added test to verify introspecting SmallIntegerFields
and fixed existing tests influenced by this change.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23357#comment:10>

Reply all
Reply to author
Forward
0 new messages