diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 0dab19ba0d9..b7be7951fca 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -192,7 +192,7 @@ def get_sql_flush(style, tables, sequences): sql.append("%s %s %s %s %s %s;" % \ (style.SQL_KEYWORD('ALTER'), style.SQL_KEYWORD('SEQUENCE'), - style.SQL_FIELD('%s_%s_seq' % (table_name, column_name)), + style.SQL_FIELD(quote_name('%s_%s_seq' % (table_name, column_name))), style.SQL_KEYWORD('RESTART'), style.SQL_KEYWORD('WITH'), style.SQL_FIELD('1') @@ -203,7 +203,7 @@ def get_sql_flush(style, tables, sequences): sql.append("%s %s %s %s %s %s;" % \ (style.SQL_KEYWORD('ALTER'), style.SQL_KEYWORD('SEQUENCE'), - style.SQL_FIELD('%s_id_seq' % table_name), + style.SQL_FIELD(quote_name('%s_id_seq' % table_name)), style.SQL_KEYWORD('RESTART'), style.SQL_KEYWORD('WITH'), style.SQL_FIELD('1') diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index 58e232df685..bc722261bb8 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -149,7 +149,7 @@ def get_sql_flush(style, tables, sequences): sql.append("%s %s %s %s %s %s;" % \ (style.SQL_KEYWORD('ALTER'), style.SQL_KEYWORD('SEQUENCE'), - style.SQL_FIELD('%s_%s_seq' % (table_name, column_name)), + style.SQL_FIELD(quote_name('%s_%s_seq' % (table_name, column_name))), style.SQL_KEYWORD('RESTART'), style.SQL_KEYWORD('WITH'), style.SQL_FIELD('1') @@ -160,7 +160,7 @@ def get_sql_flush(style, tables, sequences): sql.append("%s %s %s %s %s %s;" % \ (style.SQL_KEYWORD('ALTER'), style.SQL_KEYWORD('SEQUENCE'), - style.SQL_FIELD('%s_id_seq' % table_name), + style.SQL_FIELD(quote_name('%s_id_seq' % table_name)), style.SQL_KEYWORD('RESTART'), style.SQL_KEYWORD('WITH'), style.SQL_FIELD('1') diff --git a/tests/regressiontests/fixtures_regress/models.py b/tests/regressiontests/fixtures_regress/models.py index f9d4d350450..dd407df3533 100644 --- a/tests/regressiontests/fixtures_regress/models.py +++ b/tests/regressiontests/fixtures_regress/models.py @@ -7,6 +7,13 @@ class Animal(models.Model): def __str__(self): return self.common_name +class Plant(models.Model): + name = models.CharField(maxlength=150) + + class Meta: + # For testing when upper case letter in app name; regression for #4057 + db_table = "Fixtures_regress_plant" + __test__ = {'API_TESTS':""" >>> from django.core import management