Opened 14 years ago

Closed 14 years ago

#13183 closed (invalid)

db_table case sensitive

Reported by: noppes Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have the model:

class UserProfile(models.Model):
    user = models.ForeignKey(User)

    class Meta:
        db_table = "UserProfile"

and when i run manage.py syncdb for a second time i get this error:

python manage.py syncdb
Creating table UserProfile
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "D:\Python26\lib\site-packages\django\core\management\__init__.py", line
438, in execute_manager
    utility.execute()
  File "D:\Python26\lib\site-packages\django\core\management\__init__.py", line
379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\Python26\lib\site-packages\django\core\management\base.py", line 196,
 in run_from_argv
    self.execute(*args, **options.__dict__)
  File "D:\Python26\lib\site-packages\django\core\management\base.py", line 223,
 in execute
    output = self.handle(*args, **options)
  File "D:\Python26\lib\site-packages\django\core\management\base.py", line 352,
 in handle
    return self.handle_noargs(**options)
  File "D:\Python26\lib\site-packages\django\core\management\commands\syncdb.py"
, line 94, in handle_noargs
    cursor.execute(statement)
  File "D:\Python26\lib\site-packages\django\db\backends\util.py", line 19, in e
xecute
    return self.cursor.execute(sql, params)
  File "D:\Python26\lib\site-packages\django\db\backends\mysql\base.py", line 86
, in execute
    return self.cursor.execute(query, args)
  File "D:\Python26\lib\site-packages\MySQLdb\cursors.py", line 173, in execute
    self.errorhandler(self, exc, value)
  File "D:\Python26\lib\site-packages\MySQLdb\connections.py", line 36, in defau
lterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1050, "Table 'userprofile' already exists")

my guess is that this is a case problem.

first time I ran manage.py syncdb it said: Creating table UserProfile, but it actually created userprofile in lower case.

when i change db_table = "UserProfile" to db_table = "userprofile" i dont get the error
but I ofcourse want my database tables with capital letters

Change History (1)

comment:1 by Karen Tracey, 14 years ago

Resolution: invalid
Status: newclosed

I believe this is a configuration problem with your MySQL installation, see: http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html, not a Django bug.

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