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:
parent
3db5a64a6c
commit
7a8965a3a1
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user