Ticket #10164: sqlite_autoincrement_fix.diff

File sqlite_autoincrement_fix.diff, 2.1 KB (added by malte, 16 years ago)

fixes the problem described in the ticket

  • models/fields/__init__.py

     
    144144        except KeyError:
    145145            return None
    146146
     147    def db_type_suffix(self):
     148        data = DictWrapper(self.__dict__, connection.ops.quote_name, "qn_")
     149        try:
     150            return connection.creation.data_types_suffix[self.get_internal_type()] % data
     151        except (KeyError, AttributeError):
     152            return False
     153
    147154    def unique(self):
    148155        return self._unique or self.primary_key
    149156    unique = property(unique)
  • backends/sqlite3/creation.py

     
    3030        'TimeField':                    'time',
    3131    }
    3232   
     33    data_types_suffix = {
     34        'AutoField':                    'autoincrement',
     35    }
     36
    3337    def sql_for_pending_references(self, model, style, pending_references):
    3438        "SQLite3 doesn't support constraints"
    3539        return []
  • backends/creation.py

     
    3939        qn = self.connection.ops.quote_name
    4040        for f in opts.local_fields:
    4141            col_type = f.db_type()
     42            col_type_suffix = f.db_type_suffix()
    4243            tablespace = f.db_tablespace or opts.db_tablespace
    4344            if col_type is None:
    4445                # Skip ManyToManyFields, because they're not represented as
     
    6364                    pr = pending_references.setdefault(f.rel.to, []).append((model, f))
    6465                else:
    6566                    field_output.extend(ref_output)
     67            if col_type_suffix:
     68                field_output.append(style.SQL_KEYWORD(col_type_suffix))
    6669            table_output.append(' '.join(field_output))
    6770        if opts.order_with_respect_to:
    6871            table_output.append(style.SQL_FIELD(qn('_order')) + ' ' + \
Back to Top