Code

Ticket #4057: 4057.diff

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

fix + regression test

Line 
1=== added file 'tests/regressiontests/fixtures_regress/tests.py'
2--- tests/regressiontests/fixtures_regress/tests.py     1970-01-01 00:00:00 +0000
3+++ tests/regressiontests/fixtures_regress/tests.py     2007-04-16 18:25:48 +0000
4@@ -0,0 +1,15 @@
5+import unittest
6+from django.core import management
7+
8+class Fixtures(unittest.TestCase):
9+    def test_flush_with_upper_case_letter_in_app_name(self):
10+        # We could call django.core.managment.flush() here, but it catches the
11+        # error and prints to stderr, which won't be seen when running tests.
12+        # Also note that the test runner might not get this far if you are
13+        # running tests for more than just the fixtures_regress package since
14+        # management.flush() calls elsewhere will terminate runtests with the
15+        # same error seen here.
16+        from django.db import connection
17+        cursor = connection.cursor()
18+        for sql in management.get_sql_flush():
19+            cursor.execute(sql)
20
21=== modified file 'django/db/backends/postgresql/base.py'
22--- django/db/backends/postgresql/base.py       2007-04-09 21:05:36 +0000
23+++ django/db/backends/postgresql/base.py       2007-04-16 18:36:00 +0000
24@@ -192,7 +192,7 @@
25                 sql.append("%s %s %s %s %s %s;" % \
26                     (style.SQL_KEYWORD('ALTER'),
27                     style.SQL_KEYWORD('SEQUENCE'),
28-                    style.SQL_FIELD('%s_%s_seq' % (table_name, column_name)),
29+                    style.SQL_FIELD(quote_name('%s_%s_seq' % (table_name, column_name))),
30                     style.SQL_KEYWORD('RESTART'),
31                     style.SQL_KEYWORD('WITH'),
32                     style.SQL_FIELD('1')
33@@ -203,7 +203,7 @@
34                 sql.append("%s %s %s %s %s %s;" % \
35                     (style.SQL_KEYWORD('ALTER'),
36                      style.SQL_KEYWORD('SEQUENCE'),
37-                     style.SQL_FIELD('%s_id_seq' % table_name),
38+                     style.SQL_FIELD(quote_name('%s_id_seq' % table_name)),
39                      style.SQL_KEYWORD('RESTART'),
40                      style.SQL_KEYWORD('WITH'),
41                      style.SQL_FIELD('1')
42
43=== modified file 'django/db/backends/postgresql_psycopg2/base.py'
44--- django/db/backends/postgresql_psycopg2/base.py      2007-04-09 21:05:36 +0000
45+++ django/db/backends/postgresql_psycopg2/base.py      2007-04-16 18:36:00 +0000
46@@ -149,7 +149,7 @@
47                 sql.append("%s %s %s %s %s %s;" % \
48                     (style.SQL_KEYWORD('ALTER'),
49                      style.SQL_KEYWORD('SEQUENCE'),
50-                     style.SQL_FIELD('%s_%s_seq' % (table_name, column_name)),
51+                     style.SQL_FIELD(quote_name('%s_%s_seq' % (table_name, column_name))),
52                      style.SQL_KEYWORD('RESTART'),
53                      style.SQL_KEYWORD('WITH'),
54                      style.SQL_FIELD('1')
55@@ -160,7 +160,7 @@
56                 sql.append("%s %s %s %s %s %s;" % \
57                     (style.SQL_KEYWORD('ALTER'),
58                      style.SQL_KEYWORD('SEQUENCE'),
59-                     style.SQL_FIELD('%s_id_seq' % table_name),
60+                     style.SQL_FIELD(quote_name('%s_id_seq' % table_name)),
61                      style.SQL_KEYWORD('RESTART'),
62                      style.SQL_KEYWORD('WITH'),
63                      style.SQL_FIELD('1')
64
65=== modified file 'tests/regressiontests/fixtures_regress/models.py'
66--- tests/regressiontests/fixtures_regress/models.py    2007-04-09 21:05:36 +0000
67+++ tests/regressiontests/fixtures_regress/models.py    2007-04-16 17:42:32 +0000
68@@ -7,6 +7,13 @@
69     def __str__(self):
70         return self.common_name   
71 
72+class Plant(models.Model):
73+    name = models.CharField(maxlength=150)
74+
75+    class Meta:
76+        # For testing when upper case letter in app name.
77+        db_table = "Fixtures_regress_plant"
78+
79 __test__ = {'API_TESTS':"""
80 >>> from django.core import management
81 
82