1
0
mirror of https://github.com/django/django.git synced 2025-07-04 17:59:13 +00:00

[boulder-oracle-sprint] Added truncate_name to CREATE INDEX code

git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@3983 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Boulder Sprinters 2006-11-04 21:05:35 +00:00
parent 3db5a64a6c
commit 7a8965a3a1

View File

@ -444,6 +444,7 @@ get_sql_indexes.args = APP_ARGS
def get_sql_indexes_for_model(model):
"Returns the CREATE INDEX SQL statements for a single model"
from django.db import backend
from django.db.backends.util import truncate_name
output = []
for f in model._meta.fields:
@ -451,7 +452,7 @@ def get_sql_indexes_for_model(model):
unique = f.unique and 'UNIQUE ' or ''
output.append(
style.SQL_KEYWORD('CREATE %sINDEX' % unique) + ' ' + \
style.SQL_TABLE('%s_%s' % (model._meta.db_table, f.column)) + ' ' + \
truncate_name(style.SQL_TABLE('%s_%s' % (model._meta.db_table, f.column)), backend.get_max_name_length()) + ' ' + \
style.SQL_KEYWORD('ON') + ' ' + \
style.SQL_TABLE(backend.quote_name(model._meta.db_table)) + ' ' + \
"(%s);" % style.SQL_FIELD(backend.quote_name(f.column))