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

File boulder-oracle-sprint-firebird-rev4309.patch, 3.9 KB (added by david@…, 8 years ago)

updated patch

  • django/db/models/fields/__init__.py

     
    417417                raise validators.ValidationError, gettext_lazy("This field cannot be null.")
    418418        return str(value)
    419419
     420    def get_db_prep_save(self, value):
     421        return Field.get_db_prep_save(self, str(value))
     422
    420423    def formfield(self, initial=None):
    421424        return forms.CharField(max_length=self.maxlength, required=not self.blank, label=capfirst(self.verbose_name), initial=initial)
    422425
     
    481484    def get_db_prep_save(self, value):
    482485        # Casts dates into string format for entry into database.
    483486        if isinstance(value, datetime.datetime):
    484             if settings.DATABASE_ENGINE != 'oracle':
    485                 # Oracle does not need a string conversion
     487            if settings.DATABASE_ENGINE not in ('oracle', 'firebird'):
     488                # Oracle and Firebird does not need a string conversion
    486489                value = value.date().strftime('%Y-%m-%d')
    487490        elif isinstance(value, datetime.date):
    488             if settings.DATABASE_ENGINE != 'oracle':
    489                 # Oracle does not need a string conversion
     491            if settings.DATABASE_ENGINE not in ('oracle', 'firebird'):
     492                # Oracle and Firebird does not need a string conversion
    490493                value = value.strftime('%Y-%m-%d')
    491494        return Field.get_db_prep_save(self, value)
    492495
     
    524527            # neither database supports microseconds.
    525528            if settings.DATABASE_ENGINE in ('mysql', 'oracle') and hasattr(value, 'microsecond'):
    526529                value = value.replace(microsecond=0)
    527             # cx_Oracle wants the raw datetime instead of a string.
    528             if settings.DATABASE_ENGINE != 'oracle':
     530            # cx_Oracle and Firebird wants the raw datetime instead of a string.
     531            if settings.DATABASE_ENGINE not in ('oracle', 'firebird'):
    529532                value = str(value)
    530533        return Field.get_db_prep_save(self, value)
    531534
  • django/db/models/query.py

     
    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

     
    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:
Back to Top