﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28612	inspectdb sets max_length to -1 if no field length specified in the DB schema	rvernica	nobody	"Postgres schema:

{{{
# \d instance
                   Table ""public.instance""
       Column       |            Type             | Modifiers 
--------------------+-----------------------------+-----------
 instance_id        | bigint                      | not null
 membership_id      | bigint                      | default 0
 host               | character varying           | 
 port               | integer                     | 
 online_since       | timestamp without time zone | 
 base_path          | character varying           | 
 server_id          | integer                     | 
 server_instance_id | integer                     | 
Indexes:
    ""instance_pkey"" PRIMARY KEY, btree (instance_id)
    ""instance_host_port_key"" UNIQUE CONSTRAINT, btree (host, port)
    ""instance_host_server_id_server_instance_id_key"" UNIQUE CONSTRAINT, btree (host, server_id, server_instance_id)
    ""instance_server_id_server_instance_id_key"" UNIQUE CONSTRAINT, btree (server_id, server_instance_id)
Check constraints:
    ""instance_base_path_non_unique"" CHECK (check_base_path(base_path) = 0)
}}}

Notice the type for `host` and `base_path` attributes.

`inspectdb` output:

{{{
#!python
# python3 manage.py inspectdb instance
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#   * Rearrange models' order
#   * Make sure each model has one field with primary_key=True
#   * Make sure each ForeignKey has `on_delete` set to the desired behavior.
#   * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals

from django.db import models


class Instance(models.Model):
    instance_id = models.BigIntegerField(primary_key=True)
    membership_id = models.BigIntegerField(blank=True, null=True)
    host = models.CharField(max_length=-1, blank=True, null=True)
    port = models.IntegerField(blank=True, null=True)
    online_since = models.DateTimeField(blank=True, null=True)
    base_path = models.CharField(max_length=-1, blank=True, null=True)
    server_id = models.IntegerField(blank=True, null=True)
    server_instance_id = models.IntegerField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'instance'
        unique_together = (('host', 'port'), ('server_id', 'server_instance_id'), ('host', 'server_id', 'server_instance_id'),)
}}}

Notice the `max_length=-1` for `host` and `base_path` attributes.

The `django.contrib.postgres` app is listed in `INSTALLED_APPS`

PostgreSQL `9.6.5`
Python `3.6.1`
Django `1.11.5`"	Bug	closed	Database layer (models, ORM)	1.11	Normal	duplicate		Mariusz Felisiak	Unreviewed	0	0	0	0	0	0
