Code

Opened 6 years ago

Closed 20 months ago

#6744 closed Bug (fixed)

inspectdb doesn't set the primary_key/unique attribute on mixed case columns

Reported by: fabiocorneti Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Normal Keywords: inspectdb
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

I'm trying to use inspectdb with a legacy table like this in a MySQL db:

+---------------+--------------+------+-----+---------+----------------+
| Field         | Type         | Null | Key | Default | Extra          |
+---------------+--------------+------+-----+---------+----------------+
| idAnagrafica  | int(11)      | NO   | PRI | NULL    | auto_increment | 
| descrizione   | varchar(254) | YES  |     | NULL    |                | 

By default "idAnagrafica" is imported as "idanagrafica" in the resulting model, but it's not designated as the primary key because of the lookup on the schema dictionary is done using the lowercase attribute name.
The attached patch solves the issue for MySQL 5.0.

Attachments (1)

mixedcase_column_attributes.diff (693 bytes) - added by fabiocorneti 6 years ago.

Download all attachments as: .zip

Change History (6)

Changed 6 years ago by fabiocorneti

comment:1 Changed 6 years ago by jacob

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 3 years ago by gabrielhurley

  • Component changed from django-admin.py inspectdb to Core (Management commands)

comment:3 Changed 3 years ago by julien

  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 3 years ago by ramiro

  • Easy pickings unset
  • Keywords inspectdb added
  • UI/UX unset

comment:5 Changed 20 months ago by claudep

  • Resolution set to fixed
  • Status changed from new to closed

AFAIK this is fixed for some time already.

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.