#8573: inspectdb doesn't make use of FK information when the column name has 
upper
case characters
---------------------------------------+------------------------------------
 Reporter:  ramiro                     |       Owner:  nobody    
   Status:  new                        |   Milestone:            
Component:  django-admin.py inspectdb  |     Version:  SVN       
 Keywords:                             |       Stage:  Unreviewed
Has_patch:  0                          |  
---------------------------------------+------------------------------------
 This was reported as an [http://code.google.com/p/django-
 pyodbc/issues/detail?id=12 issue] in the [http://code.google.com/p/django-
 pyodbc/ django-pyodbc] project but after some debugging turned to be a bug
 in `inspectdb`.

 Problem is it doesn't use the real database column name but rather a
 derived `attname` value (used to represent the final Django model field
 name) when looking up the meta information about FK and indexes the DB
 backend provides via the `DatabaseIntrospection.get_relations()` method.
 This fails for database engines that are case sensitive (i.e. all but
 Oracle).

 Also, because a related problem, it can attempt to use that same `attname`
 instead of the real table column in the `db_column` field option.

 Example:

 This `models.py` file:

 {{{
 #!python
 class Magazine(models.Model):
     ident = models.AutoField(primary_key=True, db_column='Ident')

 class ReaderComment(models.Model):
     text = models.TextField(max_length=30, primary_key=True,
 db_column='reader_comment')
 }}}

 when `syncdb`ed to the database (sqlite3) and the introspected back gives:

 {{{
 #!python
 class IntrosBugMagazine(models.Model):
     ident = models.IntegerField()
     class Meta:
         db_table = u'intros_bug_magazine'

 class IntrosBugReadercomment(models.Model):
     reader_comment = models.TextField(primary_key=True)
     class Meta:
         db_table = u'intros_bug_readercomment'
 }}}

 Note the `ident` field of the `Magazine` model is missing
 `'primary_key=True'` and `db_column='Ident'` options, that's because the
 `syncdb` command didn't make use of the `'primary_key': True` info the
 database backend introspection support code correctly returned for it.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8573>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to