Code

Opened 3 years ago

Closed 3 years ago

#15612 closed (duplicate)

inspectdb guesses wrong field length

Reported by: Michael Roeller <michael.roeller@…> Owned by: nobody
Component: django-admin.py inspectdb Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When I run inspectdb against the following table

CREATE TABLE IF NOT EXISTS `REPORT_NAGIOS_SUBSERVICE` (
  `NAGIOS_SUB_SLA_ID` varchar(100) NOT NULL,
  `NAGIOS_SLA_ID` varchar(100) NOT NULL,
  `SAP_NUMMER` varchar(20) NOT NULL,
  `SERVICE_LEVEL_ID` varchar(50) NOT NULL,
  `SUBSERVICE_ID` varchar(50) NOT NULL,
  `ANZAHL_MESSPKT_GESAMT` int(3) DEFAULT NULL,
  `ANZAHL_MESSPKT_GEWICHTET` int(3) DEFAULT NULL,
  `ANZAHL_MESSPKT_LIMIT` int(3) DEFAULT NULL,
  `KOMMENTAR` varchar(1000) DEFAULT NULL,
  `TS_CREATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `TS_UPDATE` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`NAGIOS_SUB_SLA_ID`),
  UNIQUE KEY `SAP_NUMMER` (`SAP_NUMMER`,`SUBSERVICE_ID`),
  UNIQUE KEY `NAGIOS_SLA_ID` (`NAGIOS_SLA_ID`,`SUBSERVICE_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

It produces the following output:

class ReportNagiosSubservice(models.Model):
    nagios_sub_sla_id = models.CharField(max_length=300, primary_key=True, db_column='NAGIOS_SUB_SLA_ID') # Field name made lowercase.
    nagios_sla_id = models.CharField(unique=True, max_length=300, db_column='NAGIOS_SLA_ID') # Field name made lowercase.
    sap_nummer = models.CharField(unique=True, max_length=60, db_column='SAP_NUMMER') # Field name made lowercase.
    service_level_id = models.CharField(max_length=150, db_column='SERVICE_LEVEL_ID') # Field name made lowercase.
    subservice_id = models.CharField(unique=True, max_length=150, db_column='SUBSERVICE_ID') # Field name made lowercase.
    anzahl_messpkt_gesamt = models.IntegerField(null=True, db_column='ANZAHL_MESSPKT_GESAMT', blank=True) # Field name made lowercase.
    anzahl_messpkt_gewichtet = models.IntegerField(null=True, db_column='ANZAHL_MESSPKT_GEWICHTET', blank=True) # Field name made lowercase.
    anzahl_messpkt_limit = models.IntegerField(null=True, db_column='ANZAHL_MESSPKT_LIMIT', blank=True) # Field name made lowercase.
    kommentar = models.CharField(max_length=3000, db_column='KOMMENTAR', blank=True) # Field name made lowercase.
    ts_create = models.DateTimeField(db_column='TS_CREATE') # Field name made lowercase.
    ts_update = models.DateTimeField(db_column='TS_UPDATE') # Field name made lowercase.
    class Meta:
        db_table = u'REPORT_NAGIOS_SUBSERVICE'

As you can see the model field-length is three times the original field-length.

Attachments (0)

Change History (1)

comment:1 Changed 3 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

This is #5725.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.