Opened 16 years ago

Last modified 13 years ago

#9116 closed

different caps in application name producing error — at Initial Version

Reported by: Maxim Syabro <syabro@…> Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Normal Keywords: inspectdb
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have an application with name localModels and lower_case_table_names mysql variable=1, which said to MySQL automatically convert table name to lowercase.
Let's look in djnago.core.management.commnads.syncdb.py, line 67:

if connection.introspection.table_name_converter(model._meta.db_table) in tables:
    continue

connection.introspection.table_name_converter(model._meta.db_table) = 'localModels_tablename'
in tables we have
(..., 'localmodels_tablename', ...)
so here your condition doesn't work, beacuse 'localModels_tablename'!='localmodels_tablename'.
And we have an exception in manage.py syncdb:
_mysql_exceptions.OperationalError: (1050, "Table 'localmodels_tablename' already exists")

So I see at least 2 ways:

  1. Generate SQL 'CREATE TABLE tablename IF NOT EXIST'
  2. Check MySQL's lower_case_table_names variable and change condition on line 67.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top