Ticket #29949: 29949.diff

File 29949.diff, 8.0 KB (added by Tim Graham, 6 years ago)
  • django/db/backends/base/introspection.py

    diff --git a/django/db/backends/base/introspection.py b/django/db/backends/base/introspection.py
    index cefdecea0a..52da90b7e9 100644
    a b class BaseDatabaseIntrospection:  
    4040        """
    4141        return self.table_name_converter(name)
    4242
     43    def identifier_converter(self, name):
     44        """
     45        Apply a conversion to the identifier for the purposes of comparison.
     46
     47        Use table_name_converter() by default.
     48        """
     49        return self.table_name_converter(name)
     50
    4351    def table_names(self, cursor=None, include_views=False):
    4452        """
    4553        Return a list of names of all tables that exist in the database.
  • django/db/backends/oracle/introspection.py

    diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py
    index e5597fd56c..a2da8325fe 100644
    a b class DatabaseIntrospection(BaseDatabaseIntrospection):  
    186186            GROUP BY user_constraints.constraint_name, user_constraints.constraint_type
    187187        """, [table_name])
    188188        for constraint, columns, pk, unique, check in cursor.fetchall():
     189            constraint = self.identifier_converter(constraint)
    189190            constraints[constraint] = {
    190191                'columns': columns.split(','),
    191192                'primary_key': pk,
    class DatabaseIntrospection(BaseDatabaseIntrospection):  
    213214            GROUP BY cons.constraint_name, rcols.table_name, rcols.column_name
    214215        """, [table_name])
    215216        for constraint, columns, other_table, other_column in cursor.fetchall():
     217            constraint = self.identifier_converter(constraint)
    216218            constraints[constraint] = {
    217219                'primary_key': False,
    218220                'unique': False,
    class DatabaseIntrospection(BaseDatabaseIntrospection):  
    240242            GROUP BY ind.index_name, ind.index_type
    241243        """, [table_name])
    242244        for constraint, type_, columns, orders in cursor.fetchall():
     245            constraint = self.identifier_converter(constraint)
    243246            constraints[constraint] = {
    244247                'primary_key': False,
    245248                'unique': False,
  • docs/releases/2.2.txt

    diff --git a/docs/releases/2.2.txt b/docs/releases/2.2.txt
    index 4dd3c72e20..8d832e05fb 100644
    a b Database backend API  
    293293* Third party database backends must implement support for partial indexes or
    294294  set ``DatabaseFeatures.supports_partial_indexes`` to ``False``.
    295295
     296* ``DatabaseIntrospection.get_constraints()`` must return lower name constraint
     297  names, even when ``DatabaseFeatures.uppercases_column_names`` is ``True``.
     298
    296299Admin actions are no longer collected from base ``ModelAdmin`` classes
    297300----------------------------------------------------------------------
    298301
  • tests/schema/tests.py

    diff --git a/tests/schema/tests.py b/tests/schema/tests.py
    index 7f170c863e..d9dda84fec 100644
    a b class SchemaTests(TransactionTestCase):  
    18681868                table_name=AuthorWithIndexedName._meta.db_table,
    18691869                column_names=('name',),
    18701870            )
    1871         if connection.features.uppercases_column_names:
    1872             author_index_name = author_index_name.upper()
    1873             db_index_name = db_index_name.upper()
    18741871        try:
    18751872            AuthorWithIndexedName._meta.indexes = [index]
    18761873            with connection.schema_editor() as editor:
    class SchemaTests(TransactionTestCase):  
    19081905        with connection.schema_editor() as editor:
    19091906            editor.add_index(Author, index)
    19101907        if connection.features.supports_index_column_ordering:
    1911             if connection.features.uppercases_column_names:
    1912                 index_name = index_name.upper()
    19131908            self.assertIndexOrder(Author._meta.db_table, index_name, ['ASC', 'DESC'])
    19141909        # Drop the index
    19151910        with connection.schema_editor() as editor:
    class SchemaTests(TransactionTestCase):  
    21272122            editor.create_model(model)
    21282123            editor.add_field(model, field)
    21292124
    2130             constraint_name = "CamelCaseIndex"
     2125            constraint_name = 'CamelCaseIndex'
     2126            expected_constraint_name = constraint_name.lower()
    21312127            editor.execute(
    21322128                editor.sql_create_index % {
    21332129                    "table": editor.quote_name(table),
    class SchemaTests(TransactionTestCase):  
    21382134                    "condition": "",
    21392135                }
    21402136            )
    2141             if connection.features.uppercases_column_names:
    2142                 constraint_name = constraint_name.upper()
    2143             self.assertIn(constraint_name, self.get_constraints(model._meta.db_table))
     2137            self.assertIn(expected_constraint_name, self.get_constraints(model._meta.db_table))
    21442138            editor.alter_field(model, get_field(db_index=True), field, strict=True)
    2145             self.assertNotIn(constraint_name, self.get_constraints(model._meta.db_table))
     2139            self.assertNotIn(expected_constraint_name, self.get_constraints(model._meta.db_table))
    21462140
    21472141            constraint_name = "CamelCaseUniqConstraint"
     2142            expected_constraint_name = constraint_name.lower()
    21482143            editor.execute(
    21492144                editor.sql_create_unique % {
    21502145                    "table": editor.quote_name(table),
    class SchemaTests(TransactionTestCase):  
    21522147                    "columns": editor.quote_name(field.column),
    21532148                }
    21542149            )
    2155             if connection.features.uppercases_column_names:
    2156                 constraint_name = constraint_name.upper()
    2157             self.assertIn(constraint_name, self.get_constraints(model._meta.db_table))
     2150            self.assertIn(expected_constraint_name, self.get_constraints(model._meta.db_table))
    21582151            editor.alter_field(model, get_field(unique=True), field, strict=True)
    2159             self.assertNotIn(constraint_name, self.get_constraints(model._meta.db_table))
     2152            self.assertNotIn(expected_constraint_name, self.get_constraints(model._meta.db_table))
    21602153
    21612154            if editor.sql_create_fk:
    21622155                constraint_name = "CamelCaseFKConstraint"
     2156                expected_constraint_name = constraint_name.lower()
    21632157                editor.execute(
    21642158                    editor.sql_create_fk % {
    21652159                        "table": editor.quote_name(table),
    class SchemaTests(TransactionTestCase):  
    21702164                        "deferrable": connection.ops.deferrable_sql(),
    21712165                    }
    21722166                )
    2173                 if connection.features.uppercases_column_names:
    2174                     constraint_name = constraint_name.upper()
    2175                 self.assertIn(constraint_name, self.get_constraints(model._meta.db_table))
     2167                self.assertIn(expected_constraint_name, self.get_constraints(model._meta.db_table))
    21762168                editor.alter_field(model, get_field(Author, CASCADE, field_class=ForeignKey), field, strict=True)
    2177                 self.assertNotIn(constraint_name, self.get_constraints(model._meta.db_table))
     2169                self.assertNotIn(expected_constraint_name, self.get_constraints(model._meta.db_table))
    21782170
    21792171    def test_add_field_use_effective_default(self):
    21802172        """
    class SchemaTests(TransactionTestCase):  
    24912483        new_field.set_attributes_from_name('weight')
    24922484        with connection.schema_editor() as editor:
    24932485            editor.alter_field(Author, old_field, new_field, strict=True)
    2494 
    2495         expected = 'schema_author_weight_587740f9'
    2496         if connection.features.uppercases_column_names:
    2497             expected = expected.upper()
    2498         self.assertEqual(self.get_constraints_for_column(Author, 'weight'), [expected])
    2499 
     2486        self.assertEqual(self.get_constraints_for_column(Author, 'weight'), ['schema_author_weight_587740f9'])
    25002487        # Remove db_index=True to drop index.
    25012488        with connection.schema_editor() as editor:
    25022489            editor.alter_field(Author, new_field, old_field, strict=True)
Back to Top