Opened 17 years ago

Last modified 16 years ago

#7236 closed

Table containing ForeignKey created with wrong casing — at Version 5

Reported by: narendra.tumkur@… Owned by: George Vilches
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: mysql case table name lower_case_table_names
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

Here is the models.py:

class Plugin(models.Model):
	name = models.CharField(max_length=50)
	description = models.CharField(max_length=100)

class PluginContainer(models.Model):
	title = models.CharField(max_length=50)
	plugin_settings = models.CharField(max_length=2000)
	plugin = models.ForeignKey(Plugin)

PluginContainer refers to Plugin object (ForeignKey)
Running manage.py syncdb produces the tables:

App_plugin
app_plugincontainer

notice the incorrect casing on app_plugincontainer.
Removing the ForeignKey from PluginContainer correctly creates the table as App_plugincontainer

This is causing a problem with running manage.py syncdb again as it cannot find App_plugincontainer and then tries to create app_plugincontainer and fails as the table already exists.

My environment:
OS: Mac OS X 10.5
DB: MySql 5.05
Python: 2.5
Django: SVN

MySql's lower_case_table_names variable is set to 2 (default on mac os x)

Cheers
Naren

Change History (5)

comment:1 by Narendra Tumkur <narendra.tumkur@…>, 17 years ago

Resolution: invalid
Status: newclosed

Removing this ticket while I enquire in Django users

comment:2 by Narendra Tumkur <narendra.tumkur@…>, 17 years ago

Resolution: invalid
Status: closedreopened

Unable to get any response on user groups.
Added some debug statements to syncdb.py and found that the SQL statement being executed did indeed have the correct casing for the table name. However, once again, this problem happens ONLY when the model has a foreign key field. This leads me to believe this is in fact a bug within django and not MySQLdb.

comment:3 by Narendra Tumkur <narendra.tumkur@…>, 17 years ago

Component: UncategorizedDatabase wrapper

comment:4 by George Vilches, 16 years ago

Owner: changed from nobody to George Vilches
Status: reopenednew

comment:5 by Ramiro Morales, 16 years ago

Description: modified (diff)
Keywords: mysql case table name lower_case_table_names added
Note: See TracTickets for help on using tickets.
Back to Top