Ticket #1261: boulder-oracle-sprint-firebird-rev4456.diff

File boulder-oracle-sprint-firebird-rev4456.diff, 6.5 KB (added by david@…, 17 years ago)

Updated patch

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

     
    33from django.conf import settings
    44from django.core import validators
    55from django import oldforms
     6from django import newforms as forms
    67from django.core.exceptions import ObjectDoesNotExist
    78from django.utils.functional import curry
    89from django.utils.itercompat import tee
     
    419420                raise validators.ValidationError, gettext_lazy("This field cannot be null.")
    420421        return str(value)
    421422
     423    def get_db_prep_save(self, value):
     424        return Field.get_db_prep_save(self, str(value))
     425
    422426    def formfield(self, **kwargs):
    423427        defaults = {'max_length': self.maxlength, 'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
    424428        defaults.update(kwargs)
     
    485489    def get_db_prep_save(self, value):
    486490        # Casts dates into string format for entry into database.
    487491        if isinstance(value, datetime.datetime):
    488             if settings.DATABASE_ENGINE != 'oracle':
    489                 # Oracle does not need a string conversion
     492            if settings.DATABASE_ENGINE not in ('oracle', 'firebird'):
     493                # Oracle and Firebird does not need a string conversion
    490494                value = value.date().strftime('%Y-%m-%d')
    491495        elif isinstance(value, datetime.date):
    492             if settings.DATABASE_ENGINE != 'oracle':
    493                 # Oracle does not need a string conversion
     496            if settings.DATABASE_ENGINE not in ('oracle', 'firebird'):
     497                # Oracle and Firebird does not need a string conversion
    494498                value = value.strftime('%Y-%m-%d')
    495499        return Field.get_db_prep_save(self, value)
    496500
     
    530534            # neither database supports microseconds.
    531535            if settings.DATABASE_ENGINE in ('mysql', 'oracle') and hasattr(value, 'microsecond'):
    532536                value = value.replace(microsecond=0)
    533             # cx_Oracle wants the raw datetime instead of a string.
    534             if settings.DATABASE_ENGINE != 'oracle':
     537            # cx_Oracle and Firebird wants the raw datetime instead of a string.
     538            if settings.DATABASE_ENGINE not in ('oracle', 'firebird'):
    535539                value = str(value)
    536540        return Field.get_db_prep_save(self, value)
    537541
    538542    def get_db_prep_lookup(self, lookup_type, value):
    539543        # Oracle will throw an error if microseconds are given, because it
    540544        # doesn't support microseconds.
    541         if settings.DATABASE_ENGINE == 'oracle' and hasattr(value, 'microsecond'):
     545        # Firebird will throw a error if microseconds are given
     546        # and DateTime converted to String
     547        if settings.DATABASE_ENGINE in ('oracle', 'firebird') and hasattr(value, 'microsecond'):
    542548            value = value.replace(microsecond=0)
    543549        if lookup_type == 'range':
    544550            value = [str(v) for v in value]
  • django/db/models/fields/related.py

     
    335335                    (target_col_name, self.join_table, source_col_name,
    336336                    target_col_name, ",".join(['%s'] * len(new_ids))),
    337337                    [self._pk_val] + list(new_ids))
    338                 if cursor.rowcount is not None and cursor.rowcount != 0:
    339                     existing_ids = set([row[0] for row in cursor.fetchmany(cursor.rowcount)])
     338                rows = cursor.fetchall()
     339                if len(rows) != 0:
     340                    existing_ids = set([row[0] for row in rows])
    340341                else:
    341342                    existing_ids = set()
    342343
  • django/db/models/query.py

     
    707707    else:
    708708        cast_sql = '%s'
    709709    try:
    710         return '%s%s %s' % (table_prefix, field_name,
     710        lookup_sql = '%s%s %s'
     711        if (settings.DATABASE_ENGINE == 'firebird' and lookup_type[0] == 'i'):
     712            lookup_sql = 'UPPER(%s%s) %s'
     713        return lookup_sql % (table_prefix, field_name,
    711714                            backend.OPERATOR_MAPPING[lookup_type] % cast_sql)
    712715    except KeyError:
    713716        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:
  • django/contrib/redirects/models.py

     
    44
    55class Redirect(models.Model):
    66    site = models.ForeignKey(Site, radio_admin=models.VERTICAL)
    7     old_path = models.CharField(_('redirect from'), maxlength=200, db_index=True,
     7    old_path = models.CharField(_('redirect from'), maxlength=100,
    88        help_text=_("This should be an absolute path, excluding the domain name. Example: '/events/search/'."))
    9     new_path = models.CharField(_('redirect to'), maxlength=200, blank=True,
     9    new_path = models.CharField(_('redirect to'), maxlength=100, blank=True,
    1010        help_text=_("This can be either an absolute path (as above) or a full URL starting with 'http://'."))
    1111
    1212    class Meta:
Back to Top