Ticket #1261: boulder-oracle-sprint-firebird-rev4456.diff
File boulder-oracle-sprint-firebird-rev4456.diff, 6.5 KB (added by , 18 years ago) |
---|
-
django/db/models/fields/__init__.py
3 3 from django.conf import settings 4 4 from django.core import validators 5 5 from django import oldforms 6 from django import newforms as forms 6 7 from django.core.exceptions import ObjectDoesNotExist 7 8 from django.utils.functional import curry 8 9 from django.utils.itercompat import tee … … 419 420 raise validators.ValidationError, gettext_lazy("This field cannot be null.") 420 421 return str(value) 421 422 423 def get_db_prep_save(self, value): 424 return Field.get_db_prep_save(self, str(value)) 425 422 426 def formfield(self, **kwargs): 423 427 defaults = {'max_length': self.maxlength, 'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text} 424 428 defaults.update(kwargs) … … 485 489 def get_db_prep_save(self, value): 486 490 # Casts dates into string format for entry into database. 487 491 if isinstance(value, datetime.datetime): 488 if settings.DATABASE_ENGINE != 'oracle':489 # Oracle does not need a string conversion492 if settings.DATABASE_ENGINE not in ('oracle', 'firebird'): 493 # Oracle and Firebird does not need a string conversion 490 494 value = value.date().strftime('%Y-%m-%d') 491 495 elif isinstance(value, datetime.date): 492 if settings.DATABASE_ENGINE != 'oracle':493 # Oracle does not need a string conversion496 if settings.DATABASE_ENGINE not in ('oracle', 'firebird'): 497 # Oracle and Firebird does not need a string conversion 494 498 value = value.strftime('%Y-%m-%d') 495 499 return Field.get_db_prep_save(self, value) 496 500 … … 530 534 # neither database supports microseconds. 531 535 if settings.DATABASE_ENGINE in ('mysql', 'oracle') and hasattr(value, 'microsecond'): 532 536 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'): 535 539 value = str(value) 536 540 return Field.get_db_prep_save(self, value) 537 541 538 542 def get_db_prep_lookup(self, lookup_type, value): 539 543 # Oracle will throw an error if microseconds are given, because it 540 544 # 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'): 542 548 value = value.replace(microsecond=0) 543 549 if lookup_type == 'range': 544 550 value = [str(v) for v in value] -
django/db/models/fields/related.py
335 335 (target_col_name, self.join_table, source_col_name, 336 336 target_col_name, ",".join(['%s'] * len(new_ids))), 337 337 [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]) 340 341 else: 341 342 existing_ids = set() 342 343 -
django/db/models/query.py
707 707 else: 708 708 cast_sql = '%s' 709 709 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, 711 714 backend.OPERATOR_MAPPING[lookup_type] % cast_sql) 712 715 except KeyError: 713 716 pass -
django/core/management.py
163 163 # Make the definition (e.g. 'foo VARCHAR(30)') for this field. 164 164 field_output = [style.SQL_FIELD(backend.quote_name(f.column)), 165 165 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 '))) 167 167 if f.unique and (not f.primary_key or backend.allows_unique_and_pk): 168 168 field_output.append(style.SQL_KEYWORD('UNIQUE')) 169 169 if f.primary_key: … … 1177 1177 index_output = [] 1178 1178 for f in fields: 1179 1179 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 ")) 1181 1181 if f.unique: 1182 1182 field_output.append("UNIQUE") 1183 1183 if f.primary_key: -
django/contrib/redirects/models.py
4 4 5 5 class Redirect(models.Model): 6 6 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, 8 8 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, 10 10 help_text=_("This can be either an absolute path (as above) or a full URL starting with 'http://'.")) 11 11 12 12 class Meta: