mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
[boulder-oracle-sprint] fixed the *other* occurrence of oracle create sequence code with truncate_name
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4011 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
58f0b44c74
commit
abd5b14d6f
@ -243,6 +243,7 @@ def _get_sql_for_pending_references(model, pending_references):
|
||||
def _get_many_to_many_sql_for_model(model):
|
||||
from django.db import backend, get_creation_module
|
||||
from django.db.models import GenericRel
|
||||
from django.db.backends.util import truncate_name
|
||||
|
||||
data_types = get_creation_module().DATA_TYPES
|
||||
|
||||
@ -277,7 +278,8 @@ def _get_many_to_many_sql_for_model(model):
|
||||
# To simulate auto-incrementing primary keys in Oracle -- creating m2m tables
|
||||
if (settings.DATABASE_ENGINE == 'oracle'):
|
||||
m_table = f.m2m_db_table()
|
||||
sequence_statement = 'CREATE SEQUENCE %s_sq;' % m_table
|
||||
sequence_name = truncate_name('%s_sq' % m_table, backend.get_max_name_length())
|
||||
sequence_statement = 'CREATE SEQUENCE %s_sq;' % sequence_name
|
||||
final_output.append(sequence_statement)
|
||||
trigger_statement = '' + \
|
||||
'CREATE OR REPLACE trigger %s_tr\n' % m_table + \
|
||||
@ -285,7 +287,7 @@ def _get_many_to_many_sql_for_model(model):
|
||||
' for each row\n' + \
|
||||
' when (new.id is NULL)\n' + \
|
||||
' begin\n' + \
|
||||
' select %s_sq.NEXTVAL into :new.id from DUAL;\n' % m_table + \
|
||||
' select %s.NEXTVAL into :new.id from DUAL;\n' % sequence_name + \
|
||||
' end;\n'
|
||||
final_output.append(trigger_statement)
|
||||
return final_output
|
||||
|
Loading…
x
Reference in New Issue
Block a user