Django

Code

Ticket #1261: boulder-oracle-sprint-firebird-rev4212.patch

File boulder-oracle-sprint-firebird-rev4212.patch, 3.8 kB (added by david@david-elias.net, 2 years ago)
  • django/db/models/fields/__init__.py

    old new  
    407407                raise validators.ValidationError, gettext_lazy("This field cannot be null.") 
    408408        return str(value) 
    409409 
     410    def get_db_prep_save(self, value): 
     411        return Field.get_db_prep_save(self, str(value)) 
     412 
    410413# TODO: Maybe move this into contrib, because it's specialized. 
    411414class CommaSeparatedIntegerField(CharField): 
    412415    def get_manipulator_field_objs(self): 
     
    509512            if settings.DATABASE_ENGINE in ('mysql', 'oracle') and hasattr(value, 'microsecond'): 
    510513                value = value.replace(microsecond=0) 
    511514            # cx_Oracle wants the raw datetime instead of a string. 
    512             if settings.DATABASE_ENGINE != 'oracle'
     515            if settings.DATABASE_ENGINE not in ('oracle', 'firebird')
    513516                value = str(value) 
    514517        return Field.get_db_prep_save(self, value) 
    515518 
    516519    def get_db_prep_lookup(self, lookup_type, value): 
    517520        # Oracle will throw an error if microseconds are given, because it 
    518521        # doesn't support microseconds. 
    519         if settings.DATABASE_ENGINE == 'oracle' and hasattr(value, 'microsecond'): 
     522        if settings.DATABASE_ENGINE in ('oracle', 'firebird') and hasattr(value, 'microsecond'): 
    520523            value = value.replace(microsecond=0) 
    521524        if lookup_type == 'range': 
    522525            value = [str(v) for v in value] 
  • django/db/models/query.py

    old new  
    657657    else: 
    658658        cast_sql = '%s' 
    659659    try: 
    660         return '%s%s %s' % (table_prefix, field_name, 
     660        lookup_sql = '%s%s %s' 
     661        if (settings.DATABASE_ENGINE == 'firebird' and lookup_type[0] == 'i'): 
     662            lookup_sql = 'UPPER(%s%s) %s' 
     663        return lookup_sql % (table_prefix, field_name, 
    661664                            backend.OPERATOR_MAPPING[lookup_type] % cast_sql) 
    662665    except KeyError: 
    663666        pass 
  • django/core/management.py

    old new  
    163163            # Make the definition (e.g. 'foo VARCHAR(30)') for this field. 
    164164            field_output = [style.SQL_FIELD(backend.quote_name(f.column)), 
    165165                style.SQL_COLTYPE(col_type % rel_field.__dict__)] 
    166             field_output.append(style.SQL_KEYWORD('%sNULL' % (not f.null and 'NOT ' or ''))) 
     166            field_output.append(style.SQL_KEYWORD('%sNULL' % (not f.null and 'NOT ' or 'DEFAULT '))) 
    167167            if f.unique and (not f.primary_key or backend.allows_unique_and_pk): 
    168168                field_output.append(style.SQL_KEYWORD('UNIQUE')) 
    169169            if f.primary_key: 
     
    11771177    index_output = [] 
    11781178    for f in fields: 
    11791179        field_output = [backend.quote_name(f.name), data_types[f.get_internal_type()] % f.__dict__] 
    1180         field_output.append("%sNULL" % (not f.null and "NOT " or "")) 
     1180        field_output.append("%sNULL" % (not f.null and "NOT " or "DEFAULT ")) 
    11811181        if f.unique: 
    11821182            field_output.append("UNIQUE") 
    11831183        if f.primary_key: 
  • tests/runtests.py

    old new  
    1616    'django.contrib.auth', 
    1717    'django.contrib.sites', 
    1818    'django.contrib.flatpages', 
    19     'django.contrib.redirects', 
     19#    'django.contrib.redirects', 
    2020    'django.contrib.sessions', 
    2121    'django.contrib.comments', 
    2222    'django.contrib.admin',