#22637: Django migrations ignore max_length for IntegerField
----------------------------+------------------------
Reporter: msn@… | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-beta-2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------
With a model like this:
{{{
from django.db import models
class Dummy(models.Model):
id = models.IntegerField(max_length=10, primary_key=True)
}}}
`makemigrations` creates:
{{{
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Dummy',
fields=[
('id', models.IntegerField(max_length=10, serialize=False,
primary_key=True)),
],
options={
},
bases=(models.Model,),
),
]
}}}
After running the migration I run the following MySQL:
{{{
mysql> describe dummy_dummy;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0,01 sec)
}}}
I expected type to be `int(10)` but instead I get `int(11)` which is the
default for `IntegerField`. Not sure if this is expected behavior or not,
but I'd expect the `max_length` parameter to alter the type. If that's not
the case I'd be glad to hear if there's another way to alter it.
--
Ticket URL: <https://code.djangoproject.com/ticket/22637>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/062.288aeb83052324cc7cc0d8da17de35a1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.