﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16592	In MySQL, table names in unmanaged intermediate models are being lower cased	Jim Dalton	nobody	"This is an obscure error, but it's causing an error in the MySQL (InnoDB) test suite when the entire suite is run. The error can be replicated as follows:


{{{
$ ./runtests.py --settings=testproject.settings unmanaged_models  proxy_model_inheritance
Creating test database for alias 'default'...
Creating test database for alias 'other'...
...E
======================================================================
ERROR: test_table_exists (modeltests.proxy_model_inheritance.tests.ProxyModelInheritanceTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""/Users/jsdalton/webs/testproject/src/django/tests/modeltests/proxy_model_inheritance/tests.py"", line 25, in setUp
    call_command('syncdb', verbosity=0)
  File ""/Users/jsdalton/webs/testproject/src/django/django/core/management/__init__.py"", line 166, in call_command
    return klass.execute(*args, **defaults)
  File ""/Users/jsdalton/webs/testproject/src/django/django/core/management/base.py"", line 220, in execute
    output = self.handle(*args, **options)
  File ""/Users/jsdalton/webs/testproject/src/django/django/core/management/base.py"", line 351, in handle
    return self.handle_noargs(**options)
  File ""/Users/jsdalton/webs/testproject/src/django/django/core/management/commands/syncdb.py"", line 121, in handle_noargs
    custom_sql = custom_sql_for_model(model, self.style, connection)
  File ""/Users/jsdalton/webs/testproject/src/django/django/core/management/sql.py"", line 150, in custom_sql_for_model
    app_dir = os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label).__file__), 'sql'))
  File ""/Users/jsdalton/webs/testproject/src/django/django/db/models/loading.py"", line 151, in get_app
    raise ImproperlyConfigured(""App with label %s could not be found"" % app_label)
ImproperlyConfigured: App with label unmanaged_models could not be found

----------------------------------------------------------------------
Ran 4 tests in 2.080s

FAILED (errors=1)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...
}}}


In brief, the syncdb command is hiccoughing in the proxy_model_inheritance test because the previously installed model `Intermediate` (from unmanaged_model) is not getting filtered properly. The reason it is not getting filtered properly is that the db_table specified in the model definition is ""D01"" but the MySQL table name is ""d01"". In Postegres and other backends, the table name is correct as ""D01"".

I'm digging around trying to find where this is happening but I don't know this part of the code base very well. If anyone has a lead let me know and I'd be happy to put together a patch."	Bug	closed	Testing framework	dev	Normal	fixed	mysql	Jim Dalton	Ready for checkin	1	0	0	0	0	0
