1
0
mirror of https://github.com/django/django.git synced 2025-07-05 10:19:20 +00:00

[boulder-oracle-sprint] fixed m2m creation bug with oracle: management was trying to create m2m triggers for generic relations. mmmmm.... indentation.....

git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4018 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2006-11-05 01:28:59 +00:00
parent 48507721aa
commit 20a30ff32c

View File

@ -275,21 +275,22 @@ def _get_many_to_many_sql_for_model(model):
style.SQL_FIELD(backend.quote_name(f.m2m_reverse_name())))) style.SQL_FIELD(backend.quote_name(f.m2m_reverse_name()))))
table_output.append(');') table_output.append(');')
final_output.append('\n'.join(table_output)) final_output.append('\n'.join(table_output))
# To simulate auto-incrementing primary keys in Oracle -- creating m2m tables
if (settings.DATABASE_ENGINE == 'oracle'): # To simulate auto-incrementing primary keys in Oracle -- creating m2m tables
m_table = f.m2m_db_table() if (settings.DATABASE_ENGINE == 'oracle'):
sequence_name = truncate_name('%s_sq' % m_table, backend.get_max_name_length()) m_table = f.m2m_db_table()
sequence_statement = 'CREATE SEQUENCE %s;' % sequence_name sequence_name = truncate_name('%s_sq' % m_table, backend.get_max_name_length())
final_output.append(sequence_statement) sequence_statement = 'CREATE SEQUENCE %s;' % sequence_name
trigger_statement = '' + \ final_output.append(sequence_statement)
'CREATE OR REPLACE trigger %s\n' % truncate_name('%s_tr' % m_table, backend.get_max_name_length()) + \ trigger_statement = '' + \
' before insert on %s\n' % backend.quote_name(m_table) + \ 'CREATE OR REPLACE trigger %s\n' % truncate_name('%s_tr' % m_table, backend.get_max_name_length()) + \
' for each row\n' + \ ' before insert on %s\n' % backend.quote_name(m_table) + \
' when (new.id is NULL)\n' + \ ' for each row\n' + \
' begin\n' + \ ' when (new.id is NULL)\n' + \
' select %s.NEXTVAL into :new.id from DUAL;\n' % sequence_name + \ ' begin\n' + \
' end;\n' ' select %s.NEXTVAL into :new.id from DUAL;\n' % sequence_name + \
final_output.append(trigger_statement) ' end;\n'
final_output.append(trigger_statement)
return final_output return final_output
def get_sql_delete(app): def get_sql_delete(app):