Opened 11 years ago

Closed 10 years ago

#5578 closed (worksforme)

Can't import fixtures generated using mysql into postgresql

Reported by: django@… Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: postgresql mysql case sensitive sensitivity fixture load
Cc: mir@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by James Bennett)

Fixtures generated using an app running against mysql can't be imported by that same app if switched to run against postgresql. This appears to have to do with different handling of mixed case table/column names in django's drivers for the two databases.

Here's the error I get. The same error occurs regardless of fixture format. Note the case difference between spackle1_projecttemplate_subjectareas (from the exception) and spackle1_projecttemplate_subjectAreas (from the sql):

Loading 'spackle1/fixtures/spackle1' fixtures...
Installing xml fixture 'spackle1/fixtures/spackle1' from absolute path.
Traceback (most recent call last):
  File "./", line 11, in <module>
  File "/usr/lib/python2.5/site-packages/django/core/management/", line 264, in execute_manager
  File "/usr/lib/python2.5/site-packages/django/core/management/", line 215, in execute
  File "/usr/lib/python2.5/site-packages/django/core/management/", line 70, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.5/site-packages/django/core/management/", line 84, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.5/site-packages/django/core/management/commands/", line 119, in handle
  File "/usr/lib/python2.5/site-packages/django/db/backends/", line 19, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.5/site-packages/django/db/backends/postgresql/", line 47, in execute
    return self.cursor.execute(smart_str(sql, self.charset), self.format_params(params))
psycopg.ProgrammingError: ERROR:  relation "spackle1_projecttemplate_subjectareas" does not exist

SELECT setval('"spackle1_projecttemplate_subjectAreas_id_seq"', coalesce(max("id"), 1), max("id") IS NOT null) FROM spackle1_projecttemplate_subjectAreas;

Change History (4)

comment:1 Changed 11 years ago by James Bennett

Description: modified (diff)

(cleaning up formatting in description)

comment:2 Changed 11 years ago by Michael Radziej

Cc: mir@… added

comment:3 Changed 11 years ago by Simon G <dev@…>

Triage Stage: UnreviewedAccepted

comment:4 Changed 10 years ago by Jason Yan

Resolution: worksforme
Status: newclosed

This does not appear to be a bug anymore. The default table name is app_label + '_' + module_name, where module_name is the lowercase object_name. Further, the table name in this example is not quoted, however in the latest trunk it is quoted, so if db_table is set to a name with upper-casing, the code still works.

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