Ticket #8901: 8901-fixindextruncation.diff

File 8901-fixindextruncation.diff, 951 bytes (added by Skaffen, 14 years ago)

Call truncate_name in postgresql index creation to avoid letting postgres truncate the name badly

  • django/db/backends/postgresql/creation.py

    a b  
    11from django.db.backends.creation import BaseDatabaseCreation
     2from django.db.backends.util import truncate_name
    23
    34class DatabaseCreation(BaseDatabaseCreation):
    45    # This dictionary maps Field objects to their associated PostgreSQL column
     
    5152
    5253            def get_index_sql(index_name, opclass=''):
    5354                return (style.SQL_KEYWORD('CREATE INDEX') + ' ' +
    54                         style.SQL_TABLE(qn(index_name)) + ' ' +
     55                        style.SQL_TABLE(qn(truncate_name(index_name,self.connection.ops.max_name_length()))) + ' ' +
    5556                        style.SQL_KEYWORD('ON') + ' ' +
    5657                        style.SQL_TABLE(qn(db_table)) + ' ' +
    5758                        "(%s%s)" % (style.SQL_FIELD(qn(f.column)), opclass) +
Back to Top