inspectdb doesn't make use of FK and uniqueness information when the column name has upper case characters
|Reported by:||Ramiro Morales||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by )
Problem is it doesn't use the real database column name but rather a derived
att_name 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 of a related problem, it can attempt to use that same innaccurate
att_name instead of the real table column when trying to introspect the
db_column field option.
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')
syncdbed to the database (sqlite3) and the introspected back gives:
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'
ident field of the
Magazine model is missing:
'primary_key=True'option(that's because the
syncdbcommand didn't make use of the
'primary_key': Trueinfo the database backend introspection support code correctly returned for it.)
Change History (5)
comment:1 Changed 8 years ago by
|Patch needs improvement:||unset|
comment:2 Changed 8 years ago by
|Summary:||inspectdb doesn't make use of FK information when the column name has upper case characters → inspectdb doesn't make use of FK and uniqueness information when the column name has upper case characters|