[Django] #24365: inspectdb should generate PositiveIntegerFields for unsigned fields.

16 views
Skip to first unread message

Django

unread,
Feb 19, 2015, 2:41:55 AM2/19/15
to django-...@googlegroups.com
#24365: inspectdb should generate PositiveIntegerFields for unsigned fields.
-------------------------------------+-------------------------------------
Reporter: bharadwaj6 | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Keywords: inspectdb, unsigned,
Severity: Normal | positiveintegerfield
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
I have tested this on MySQL and Django 1.7.4.

I have unsigned integer fields in my mysql table (which can be created
from SQL like this: `entity_id int(10) unsigned NOT NULL COMMENT 'Entity
ID'`), and when I introspect a table that contains fields like this, the
corresponding model field generated is:

`entity_id = models.IntegerField()`,

whereas it should be something like:

`entity_id = models.PositiveIntegerField()`.

This is same in case of unsigned smallint fields too.

A bug like this also breaks ForeignKey relationships on that field, as the
new field created would be a normal INT and results in MySQL error 150
during migrations and breaks them. Changing the fields to
`PositiveIntegerField` in generated file manually seems like the only fix
for now (which was suggested to me on #django IRC).

So, `inspectdb` should generate `PositiveIntegerField` when the field is
unsigned. I am not sure if this is the same for other databases too, as I
haven't tested against them.

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

Django

unread,
Feb 19, 2015, 12:38:06 PM2/19/15
to django-...@googlegroups.com
#24365: inspectdb should generate PositiveIntegerFields for unsigned fields.
-------------------------------------+-------------------------------------
Reporter: bharadwaj6 | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb, | Triage Stage: Accepted
unsigned, positiveintegerfield |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* needs_better_patch: => 0
* component: Database layer (models, ORM) => Core (Management commands)
* needs_tests: => 0
* version: 1.7 => master
* needs_docs: => 0
* stage: Unreviewed => Accepted


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

Django

unread,
Feb 21, 2015, 4:24:01 PM2/21/15
to django-...@googlegroups.com
#24365: inspectdb should generate PositiveIntegerFields for unsigned fields.
-------------------------------------+-------------------------------------
Reporter: bharadwaj6 | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb, | Triage Stage: Accepted
unsigned, positiveintegerfield, |
mysql |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* keywords: inspectdb, unsigned, positiveintegerfield => inspectdb,
unsigned, positiveintegerfield, mysql


Comment:

AFAIK, this is a MySQL specific issue, as other backends don't care about
signed/unsigned.

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

Django

unread,
Feb 24, 2015, 1:15:49 AM2/24/15
to django-...@googlegroups.com
#24365: inspectdb should generate PositiveIntegerFields for unsigned fields.
-------------------------------------+-------------------------------------
Reporter: bharadwaj6 | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb, | Triage Stage: Accepted
unsigned, positiveintegerfield, |
mysql |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by bharadwaj6):

Replying to [comment:2 claudep]:


> AFAIK, this is a MySQL specific issue, as other backends don't care
about signed/unsigned.

Is this issue an easy picking?

If yes, I would like to fix this myself. :)

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

Django

unread,
Feb 24, 2015, 4:26:09 AM2/24/15
to django-...@googlegroups.com
#24365: inspectdb should generate PositiveIntegerFields for unsigned fields.
-------------------------------------+-------------------------------------
Reporter: bharadwaj6 | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb, | Triage Stage: Accepted
unsigned, positiveintegerfield, |
mysql |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by claudep):

Feel free to try. I can assist you if needed.

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

Django

unread,
Jul 16, 2015, 11:48:38 PM7/16/15
to django-...@googlegroups.com
#24365: inspectdb should generate PositiveIntegerFields for unsigned fields.
-------------------------------------+-------------------------------------
Reporter: bharadwaj6 | Owner:
| earthling-shruti
Type: Bug | Status: assigned

Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb, | Triage Stage: Accepted
unsigned, positiveintegerfield, |
mysql |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* status: new => assigned
* owner: nobody => earthling-shruti


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

Django

unread,
Jul 17, 2015, 12:41:59 AM7/17/15
to django-...@googlegroups.com
#24365: inspectdb should generate PositiveIntegerFields for unsigned fields.
-------------------------------------+-------------------------------------
Reporter: bharadwaj6 | Owner:
| earthling-shruti
Type: Bug | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb, | Triage Stage: Accepted
unsigned, positiveintegerfield, |
mysql |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

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


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

Django

unread,
Mar 30, 2016, 7:23:02 AM3/30/16
to django-...@googlegroups.com
#24365: inspectdb should generate PositiveIntegerFields for unsigned fields.
-------------------------------------+-------------------------------------
Reporter: bharadwaj6 | Owner:
Type: Bug | Status: new

Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb, | Triage Stage: Accepted
unsigned, positiveintegerfield, |
mysql |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* owner: earthling-shruti =>
* status: assigned => new


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

Django

unread,
Mar 7, 2017, 7:53:57 AM3/7/17
to django-...@googlegroups.com
#24365: inspectdb should generate PositiveIntegerFields for unsigned fields.
-------------------------------------+-------------------------------------
Reporter: Bharadwaj | Owner: felixxm
Srigiriraju |
Type: Bug | Status: assigned

Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb, | Triage Stage: Accepted
unsigned, positiveintegerfield, |
mysql |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* owner: (none) => felixxm
* needs_better_patch: 1 => 0
* has_patch: 1 => 0


* status: new => assigned


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

Django

unread,
Mar 7, 2017, 8:29:23 AM3/7/17
to django-...@googlegroups.com
#24365: inspectdb should generate PositiveIntegerFields for unsigned fields.
-------------------------------------+-------------------------------------
Reporter: Bharadwaj | Owner: felixxm
Srigiriraju |
Type: Bug | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: inspectdb, | Triage Stage: Accepted
unsigned, positiveintegerfield, |
mysql |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/8151 PR]

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

Django

unread,
Mar 8, 2017, 10:56:09 AM3/8/17
to django-...@googlegroups.com
#24365: inspectdb should generate PositiveIntegerFields for unsigned fields.
-------------------------------------+-------------------------------------
Reporter: Bharadwaj | Owner: felixxm
Srigiriraju |
Type: Bug | Status: closed

Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed

Keywords: inspectdb, | Triage Stage: Accepted
unsigned, positiveintegerfield, |
mysql |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"94d8bea212441ebfafcab10d245285581e701c54" 94d8bea2]:
{{{
#!CommitTicketReference repository=""
revision="94d8bea212441ebfafcab10d245285581e701c54"
Fixed #24365 -- Made inspectdb translate MySQL unsigned integer columns to
positive integer fields.
}}}

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

Reply all
Reply to author
Forward
0 new messages