Ticket #13821: 13832.diff
File 13832.diff, 3.5 KB (added by , 14 years ago) |
---|
-
django/db/backends/postgresql/operations.py
56 56 def last_insert_id(self, cursor, table_name, pk_name): 57 57 # Use pg_get_serial_sequence to get the underlying sequence name 58 58 # from the table name and column name (available since PostgreSQL 8) 59 cursor.execute("SELECT CURRVAL(pg_get_serial_sequence('%s','%s'))" % (table_name, pk_name)) 59 cursor.execute("SELECT CURRVAL(pg_get_serial_sequence('%s','%s'))" % ( 60 self.quote_name(table_name), pk_name)) 60 61 return cursor.fetchone()[0] 61 62 62 63 def no_limit_value(self): … … 98 99 column_name = 'id' 99 100 sql.append("%s setval(pg_get_serial_sequence('%s','%s'), 1, false);" % \ 100 101 (style.SQL_KEYWORD('SELECT'), 101 style.SQL_TABLE( table_name),102 style.SQL_TABLE(self.quote_name(table_name)), 102 103 style.SQL_FIELD(column_name)) 103 104 ) 104 105 return sql … … 120 121 if isinstance(f, models.AutoField): 121 122 output.append("%s setval(pg_get_serial_sequence('%s','%s'), coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \ 122 123 (style.SQL_KEYWORD('SELECT'), 123 style.SQL_TABLE( model._meta.db_table),124 style.SQL_TABLE(self.quote_name(model._meta.db_table)), 124 125 style.SQL_FIELD(f.column), 125 126 style.SQL_FIELD(qn(f.column)), 126 127 style.SQL_FIELD(qn(f.column)), … … 132 133 if not f.rel.through: 133 134 output.append("%s setval(pg_get_serial_sequence('%s','%s'), coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \ 134 135 (style.SQL_KEYWORD('SELECT'), 135 style.SQL_TABLE( model._meta.db_table),136 style.SQL_TABLE(self.quote_name(model._meta.db_table)), 136 137 style.SQL_FIELD('id'), 137 138 style.SQL_FIELD(qn('id')), 138 139 style.SQL_FIELD(qn('id')), -
tests/regressiontests/Bug13832/__init__.py
1 -
tests/regressiontests/Bug13832/tests.py
1 from django.test import TestCase 2 from regressiontests.Bug13832 import models 3 4 class TestUppercaseAppNames(TestCase): 5 """ Ensure app labels with uppercase characters don't cause DatabaseErrors. 6 7 (As they did after changeset #13363, when using PostgreSQL). 8 """ 9 def test_uppercase(self): 10 models.AppNameTestClass.objects.create() -
tests/regressiontests/Bug13832/models.py
1 from django.db import models 2 3 class AppNameTestClass(models.Model): 4 token_field = models.CharField(max_length=255) 5