Bug #74337 Connector/Python Django Backend BaseDatabase get_table_list API was changed
Submitted: 12 Oct 2014 12:35 Modified: 18 Apr 2018 8:05
Reporter: zulan zulan Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:2.0.1 OS:Linux
Assigned to: CPU Architecture:Any
Tags: Django

[12 Oct 2014 12:35] zulan zulan
Description:
The API of BaseDatabase get_table_list was changed in this commit: https://github.com/django/django/commit/b8cdc7dcc3fc6897fb2a75f90023f5c67aad327f

Trying to run the Django test i18n with the mysql-connector backend fails with the following error. django.db.backends.sqlite3, django.db.backends.mysql complete the test with no errors.

Creating test database for alias 'default'...
Traceback (most recent call last):
  File "./runtests.py", line 391, in <module>
    options.failfast, options.modules)
  File "./runtests.py", line 234, in django_tests
    test_labels or get_installed(), extra_tests=extra_tests)
  File "django-git/django/django/test/runner.py", line 151, in run_tests
    old_config = self.setup_databases()
  File "django-git/django/django/test/runner.py", line 113, in setup_databases
    return setup_databases(self.verbosity, self.interactive, self.keepdb, **kwargs)
  File "django-git/django/django/test/runner.py", line 304, in setup_databases
    serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
  File "django-git/django/django/db/backends/creation.py", line 385, in create_test_db
    test_flush=True,
  File "django-git/django/django/core/management/__init__.py", line 118, in call_command
    return command.execute(*args, **defaults)
  File "django-git/django/django/core/management/base.py", line 419, in execute
    output = self.handle(*args, **options)
  File "django-git/django/django/core/management/commands/migrate.py", line 154, in handle
    created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
  File "django-git/django/django/core/management/commands/migrate.py", line 224, in sync_apps
    tables = connection.introspection.table_names(cursor)
  File "django-git/django/django/db/backends/__init__.py", line 1310, in table_names
    return get_names(cursor)
  File "django-git/django/django/db/backends/__init__.py", line 1305, in get_names
    return sorted([ti.name for ti in self.get_table_list(cursor)
  File "django-git/django/django/db/backends/__init__.py", line 1306, in <listcomp>
    if include_views or ti.type == 't'])
AttributeError: 'str' object has no attribute 'type'

How to repeat:
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests

$ git clone https://github.com/django/django.git django-repo
$ cd django-repo/tests
$ cp test_sqlite.py test_mysql_connector.py
edit test_mysql_connector.py to to use 'ENGINE': 'mysql.connector.django', with appropriate settings
$ PYTHONPATH=..:$PYTHONPATH ./runtests.py i18n
Even more Errors
$ PYTHONPATH=..:$PYTHONPATH ./runtests.py 

Suggested fix:
either different versions for different django versions or if version == …
[31 Oct 2014 10:19] Geert Vanderkelen
Hallo, thanks for reporting this.

The commit to Django is to the development branch. This is not in a current release version as far as we know. Can you confirm?

If this is still in the development branch, there might be a chance that it will change again. So fixing this for Django Dev branch might not be a good idea. What do you think?
[3 Nov 2014 21:09] zulan zulan
> The commit to Django is to the development branch. This is not in a current release version as far as we know. Can you confirm?

Yes.

I was running into some trouble so I decided to run the tests as documented there
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/#runn...
This is based on the git version.

> If this is still in the development branch, there might be a chance that it will change again. So fixing this for Django Dev branch might not be a good idea. What do you think?

Well this sort of change is very nasty to handle. At least I wanted to give a heads-up. Considering it is likely that this change ends up in 1.8 (I have no Idea what the chances of additional changes are) - users will probably run into issues once 1.8 is released and they update to 1.8 - but not update the Connector. So acting now would be better. I think the only way to resolve this is getting into contact with the Django developers.
[18 Apr 2018 8:05] Chiranjeevi Battula
Hello zulan,

Thank you for the bug report.
I tried with latest versions of MySQL Connector / Python 2.1.7 and it worked without any issues.
Probably this is fixed, please feel free to reopen this bug report if you encounter this issue again.

Thanks,
Chiranjeevi.