Ticket #4057: 4057.diff

File 4057.diff, 3.8 KB (added by Gary Wilson <gary.wilson@…>, 18 years ago)

fix + regression test

  • tests/regressiontests/fixtures_regress/tests.py

    === added file 'tests/regressiontests/fixtures_regress/tests.py'
     
     1import unittest
     2from django.core import management
     3
     4class Fixtures(unittest.TestCase):
     5    def test_flush_with_upper_case_letter_in_app_name(self):
     6        # We could call django.core.managment.flush() here, but it catches the
     7        # error and prints to stderr, which won't be seen when running tests.
     8        # Also note that the test runner might not get this far if you are
     9        # running tests for more than just the fixtures_regress package since
     10        # management.flush() calls elsewhere will terminate runtests with the
     11        # same error seen here.
     12        from django.db import connection
     13        cursor = connection.cursor()
     14        for sql in management.get_sql_flush():
     15            cursor.execute(sql)
  • django/db/backends/postgresql/base.py

    === modified file 'django/db/backends/postgresql/base.py'
     
    192192                sql.append("%s %s %s %s %s %s;" % \
    193193                    (style.SQL_KEYWORD('ALTER'),
    194194                    style.SQL_KEYWORD('SEQUENCE'),
    195                     style.SQL_FIELD('%s_%s_seq' % (table_name, column_name)),
     195                    style.SQL_FIELD(quote_name('%s_%s_seq' % (table_name, column_name))),
    196196                    style.SQL_KEYWORD('RESTART'),
    197197                    style.SQL_KEYWORD('WITH'),
    198198                    style.SQL_FIELD('1')
     
    203203                sql.append("%s %s %s %s %s %s;" % \
    204204                    (style.SQL_KEYWORD('ALTER'),
    205205                     style.SQL_KEYWORD('SEQUENCE'),
    206                      style.SQL_FIELD('%s_id_seq' % table_name),
     206                     style.SQL_FIELD(quote_name('%s_id_seq' % table_name)),
    207207                     style.SQL_KEYWORD('RESTART'),
    208208                     style.SQL_KEYWORD('WITH'),
    209209                     style.SQL_FIELD('1')
  • django/db/backends/postgresql_psycopg2/base.py

    === modified file 'django/db/backends/postgresql_psycopg2/base.py'
     
    149149                sql.append("%s %s %s %s %s %s;" % \
    150150                    (style.SQL_KEYWORD('ALTER'),
    151151                     style.SQL_KEYWORD('SEQUENCE'),
    152                      style.SQL_FIELD('%s_%s_seq' % (table_name, column_name)),
     152                     style.SQL_FIELD(quote_name('%s_%s_seq' % (table_name, column_name))),
    153153                     style.SQL_KEYWORD('RESTART'),
    154154                     style.SQL_KEYWORD('WITH'),
    155155                     style.SQL_FIELD('1')
     
    160160                sql.append("%s %s %s %s %s %s;" % \
    161161                    (style.SQL_KEYWORD('ALTER'),
    162162                     style.SQL_KEYWORD('SEQUENCE'),
    163                      style.SQL_FIELD('%s_id_seq' % table_name),
     163                     style.SQL_FIELD(quote_name('%s_id_seq' % table_name)),
    164164                     style.SQL_KEYWORD('RESTART'),
    165165                     style.SQL_KEYWORD('WITH'),
    166166                     style.SQL_FIELD('1')
  • tests/regressiontests/fixtures_regress/models.py

    === modified file 'tests/regressiontests/fixtures_regress/models.py'
     
    77    def __str__(self):
    88        return self.common_name   
    99
     10class Plant(models.Model):
     11    name = models.CharField(maxlength=150)
     12
     13    class Meta:
     14        # For testing when upper case letter in app name.
     15        db_table = "Fixtures_regress_plant"
     16
    1017__test__ = {'API_TESTS':"""
    1118>>> from django.core import management
    1219
Back to Top