Opened 17 years ago
Closed 17 years ago
#4678 closed (fixed)
second and subsequent runs of syncdb fails with "table already exists"
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | ||
Cc: | tailofthesun@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
I'm using postgresql and psycopg2. I'm new to django so I just tried to follow the steps described in the tutorial. When I ran syncdb for the second time (after creating the model) I got the following:
$ python manage.py syncdb Creating table auth_message Traceback (most recent call last): File "manage.py", line 11, in ? execute_manager(settings) File "/usr/lib/python2.4/site-packages/django/core/management.py", line 1736, in execute_manager execute_from_command_line(action_mapping, argv) File "/usr/lib/python2.4/site-packages/django/core/management.py", line 1633, in execute_from_command_line action_mapping[action](int(options.verbosity), options.interactive) File "/usr/lib/python2.4/site-packages/django/core/management.py", line 572, in syncdb cursor.execute(statement) File "/usr/lib/python2.4/site-packages/django/db/backends/util.py", line 18, in execute return self.cursor.execute(sql, params) psycopg2.ProgrammingError: relation "auth_message" already exists
Attachments (1)
Change History (6)
comment:1 by , 17 years ago
Cc: | added |
---|
by , 17 years ago
Attachment: | postgresql_psycopg2-base.diff added |
---|
comment:2 by , 17 years ago
Has patch: | set |
---|
Actually, PostgreSQL does use case sensitive table names. I also noticed the postgresql backend sets uses_case_insensitive_names to False, so I've attached a patch for the postgresql_psycopg2 backend.
comment:3 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
I've tracked the bug to core/management.py:543 in revision [5519]. The table_list is returned as a sequence of lower-case strings. Since PostgreSQL uses case insensitive names, the name of each table compared to table_list is uppercased, and thus the comparison on line 560 always evaluates to False. I'm not sure how the other backends work, but at least for postgresql_psycopg2, the names should not be uppercased.