﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
5366	sequence_reset_sql table name quoting problem (PostgreSQL backend)	alex@…	nobody	"
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/operations.py
===================================================================
--- django/db/backends/postgresql/operations.py (revision 6066)
+++ django/db/backends/postgresql/operations.py (working copy)
@@ -100,5 +100,5 @@
                     style.SQL_FIELD(qn('id')),
                     style.SQL_KEYWORD('IS NOT'),
                     style.SQL_KEYWORD('FROM'),
-                    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
 1. Name one of your application with big case letter (ex: instead of fixtures_regress application I had to name
    it FixturesRegress)
 1. Try to dumpdata/loaddata.

Got:

{{{
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.
"		closed	Database layer (models, ORM)	dev		fixed	quote fixture postgresql	alex@…	Unreviewed	1	0	0	0	0	0
