Opened 9 years ago

Closed 9 years ago

#5366 closed (fixed)

sequence_reset_sql table name quoting problem (PostgreSQL backend)

Reported by: alex@… Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: quote fixture postgresql
Cc: alex@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I have recently run into trouble of using fixtures with PostgreSQL. Any attempt to use them for my application
produced a number of SQL errors of not existing tables. I found that this problem was caused by missing
quoting of a table name, added it, and it fixed the problem.

Index: django/db/backends/postgresql/
--- django/db/backends/postgresql/ (revision 6066)
+++ django/db/backends/postgresql/ (working copy)
@@ -100,5 +100,5 @@
                     style.SQL_KEYWORD('IS NOT'),
-                    style.SQL_TABLE(f.m2m_db_table())))
+                    style.SQL_TABLE(qn(f.m2m_db_table()))))
         return output

To reproduce problem:

  1. Use postgresql_psycopg2 as your database adapter
  2. Name one of your application with big case letter (ex: instead of fixtures_regress application I had to name it FixturesRegress)
  3. Try to dumpdata/loaddata.


SELECT ... FROM FixturesRegress_stuff_shared_with;

Must be:

SELECT ... FROM "FixturesRegress_stuff_shared_with"

PosgreSQL reaction to a wrong quoting:

    ProgrammingError: relation "fixturesregress_stuff_shared_with" does not exist

The difference is that quoting must be present in table name for !PostgreSQL to recognize this table.

Since successful testing depends on application name, we can not use our fixtures_regress folder to just add a
single test.

To prove the problem existence I have made a simple test app and attaching it to this ticket,
as a ready test, but please fix me and provide a different patch if this is not the kind of test you require
for a successful ticket acceptance.

Attachments (1)

alex_db_operations.diff (553 bytes) - added by alex@… 9 years ago.
Patch to fix table quoting

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by alex@…

Attachment: alex_db_operations.diff added

Patch to fix table quoting

comment:1 Changed 9 years ago by alex@…

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

I can not add test file to this ticket due to "Trac internal server error" (see so
I have posted zip archive with test on my site:

comment:2 Changed 9 years ago by Gary Wilson

Resolution: fixed
Status: newclosed

This was fixed in [6507]. The file doesn't seem to exist anymore. Tests would be nice though, so if you still have them please open a new ticket.

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