home / django_tickets / tickets

tickets: 8573

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
8573 2008-08-26 21:24:34 2008-09-17 05:15:02 2022-03-06 03:42:36.735178 Unreviewed closed django-admin.py inspectdb     dev fixed inspectdb doesn't make use of FK and uniqueness information when the column name has upper case characters 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 `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. 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: a. The `'primary_key=True'`option(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.) b. The `db_column='Ident'` option nobody ramiro   0 1 0 0 0 0
Powered by Datasette · Queries took 0.863ms