Ticket #11107: many_to_many.rel.through.3.diff
File many_to_many.rel.through.3.diff, 2.8 KB (added by , 15 years ago) |
---|
-
django/db/backends/postgresql/operations.py
121 121 style.SQL_TABLE(qn(model._meta.db_table)))) 122 122 break # Only one AutoField is allowed per model, so don't bother continuing. 123 123 for f in model._meta.many_to_many: 124 output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \ 125 (style.SQL_KEYWORD('SELECT'), 126 style.SQL_FIELD(qn('%s_id_seq' % f.m2m_db_table())), 127 style.SQL_FIELD(qn('id')), 128 style.SQL_FIELD(qn('id')), 129 style.SQL_KEYWORD('IS NOT'), 130 style.SQL_KEYWORD('FROM'), 131 style.SQL_TABLE(qn(f.m2m_db_table())))) 124 if not f.rel.through: 125 output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \ 126 (style.SQL_KEYWORD('SELECT'), 127 style.SQL_FIELD(qn('%s_id_seq' % f.m2m_db_table())), 128 style.SQL_FIELD(qn('id')), 129 style.SQL_FIELD(qn('id')), 130 style.SQL_KEYWORD('IS NOT'), 131 style.SQL_KEYWORD('FROM'), 132 style.SQL_TABLE(qn(f.m2m_db_table())))) 132 133 return output 133 134 134 135 def savepoint_create_sql(self, sid): -
django/db/backends/oracle/base.py
217 217 # continue to loop 218 218 break 219 219 for f in model._meta.many_to_many: 220 table_name = self.quote_name(f.m2m_db_table()) 221 sequence_name = get_sequence_name(f.m2m_db_table()) 222 column_name = self.quote_name('id') 223 output.append(query % {'sequence': sequence_name, 224 'table': table_name, 225 'column': column_name}) 220 if not f.rel.through: 221 table_name = self.quote_name(f.m2m_db_table()) 222 sequence_name = get_sequence_name(f.m2m_db_table()) 223 column_name = self.quote_name('id') 224 output.append(query % {'sequence': sequence_name, 225 'table': table_name, 226 'column': column_name}) 226 227 return output 227 228 228 229 def start_transaction_sql(self):