Ticket #10164: Django-1.3-sqlite.patch

File Django-1.3-sqlite.patch, 2.2 KB (added by Jonttu, 14 years ago)

Patch modified for 1.3

  • django/db/backends/creation.py

    old new  
    4040        qn = self.connection.ops.quote_name
    4141        for f in opts.local_fields:
    4242            col_type = f.db_type(connection=self.connection)
     43            col_type_suffix = f.db_type_suffix(connection=self.connection)
    4344            tablespace = f.db_tablespace or opts.db_tablespace
    4445            if col_type is None:
    4546                # Skip ManyToManyFields, because they're not represented as
     
    6465                    pr = pending_references.setdefault(f.rel.to, []).append((model, f))
    6566                else:
    6667                    field_output.extend(ref_output)
     68            if col_type_suffix:
     69                field_output.append(style.SQL_KEYWORD(col_type_suffix))
    6770            table_output.append(' '.join(field_output))
    6871        for field_constraints in opts.unique_together:
    6972            table_output.append(style.SQL_KEYWORD('UNIQUE') + ' (%s)' % \
  • django/db/backends/sqlite3/creation.py

    old new  
    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 []
  • django/db/models/fields/__init__.py

    old new  
    221221        except KeyError:
    222222            return None
    223223
     224    def db_type_suffix(self, connection):
     225        data = DictWrapper(self.__dict__, connection.ops.quote_name, "qn_")
     226        try:
     227            return connection.creation.data_types_suffix[self.get_internal_type()] % data
     228        except (KeyError, AttributeError):
     229            return False
     230
    224231    def unique(self):
    225232        return self._unique or self.primary_key
    226233    unique = property(unique)
Back to Top