Opened 18 years ago
Last modified 17 years ago
#7236 closed
Table containing ForeignKey created with wrong casing — at Version 5
| Reported by: | 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 )
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 , 18 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
comment:2 by , 18 years ago
| Resolution: | invalid |
|---|---|
| Status: | closed → reopened |
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 , 18 years ago
| Component: | Uncategorized → Database wrapper |
|---|
comment:4 by , 17 years ago
| Owner: | changed from to |
|---|---|
| Status: | reopened → new |
comment:5 by , 17 years ago
| Description: | modified (diff) |
|---|---|
| Keywords: | mysql case table name lower_case_table_names added |
Removing this ticket while I enquire in Django users