#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. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/053.56fe10362d05dc6477a05e03e688cf9d%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.