Ticket #7407: oracle_sequence_reset_quote_name.patch

File oracle_sequence_reset_quote_name.patch, 2.5 KB (added by erny, 16 years ago)

Patches db/backends/oracle/base.py to correct table name quoting in sequence_reset_sql

  • django/db/backends/oracle/base.py

     
    145145            # Since we've just deleted all the rows, running our sequence
    146146            # ALTER code will reset the sequence to 0.
    147147            for sequence_info in sequences:
    148                 table_name = sequence_info['table']
    149                 seq_name = get_sequence_name(table_name)
     148                sequence_name = get_sequence_name(sequence_info['table'])
     149                table_name = self.quote_name(sequence_info['table'])
    150150                column_name = self.quote_name(sequence_info['column'] or 'id')
    151                 query = _get_sequence_reset_sql() % {'sequence': seq_name,
    152                                                      'table': self.quote_name(table_name),
     151                query = _get_sequence_reset_sql() % {'sequence': sequence_name,
     152                                                     'table': table_name,
    153153                                                     'column': column_name}
    154154                sql.append(query)
    155155            return sql
     
    164164            for f in model._meta.fields:
    165165                if isinstance(f, models.AutoField):
    166166                    sequence_name = get_sequence_name(model._meta.db_table)
     167                    table_name = self.quote_name(model._meta.db_table)
    167168                    column_name = self.quote_name(f.db_column or f.name)
    168169                    output.append(query % {'sequence': sequence_name,
    169                                            'table': model._meta.db_table,
     170                                           'table': table_name,
    170171                                           'column': column_name})
    171172                    break # Only one AutoField is allowed per model, so don't bother continuing.
    172173            for f in model._meta.many_to_many:
    173174                sequence_name = get_sequence_name(f.m2m_db_table())
     175                table_name = self.quote_name(f.m2m_db_table())
     176                column_name = self.quote_name('id')
    174177                output.append(query % {'sequence': sequence_name,
    175                                        'table': f.m2m_db_table(),
    176                                        'column': self.quote_name('id')})
     178                                       'table': table_name,
     179                                       'column': column_name})
    177180        return output
    178181
    179182    def start_transaction_sql(self):
Back to Top