Ticket #1261: firebird_backend_patch_6650.diff
File firebird_backend_patch_6650.diff, 9.9 KB (added by , 17 years ago) |
---|
-
django/db/models/fields/__init__.py
206 206 return value 207 207 208 208 def get_db_prep_lookup(self, lookup_type, value): 209 from django.db import connection 209 210 "Returns field's value prepared for database lookup." 210 211 if lookup_type in ('exact', 'regex', 'iregex', 'gt', 'gte', 'lt', 'lte', 'month', 'day', 'search'): 211 212 return [value] 212 213 elif lookup_type in ('range', 'in'): 213 214 return value 214 215 elif lookup_type in ('contains', 'icontains'): 216 if connection.features.uses_custom_icontains and lookup_type == 'icontains': 217 return [value] 215 218 return ["%%%s%%" % prep_for_like_query(value)] 216 219 elif lookup_type == 'iexact': 217 220 return [prep_for_like_query(value)] 218 221 elif lookup_type in ('startswith', 'istartswith'): 222 if connection.features.uses_custom_startswith: 223 return [value] 219 224 return ["%s%%" % prep_for_like_query(value)] 220 225 elif lookup_type in ('endswith', 'iendswith'): 221 226 return ["%%%s" % prep_for_like_query(value)] … … 478 483 defaults.update(kwargs) 479 484 return super(CharField, self).formfield(**defaults) 480 485 486 class ASCIICharField(CharField): 487 pass 488 481 489 # TODO: Maybe move this into contrib, because it's specialized. 482 490 class CommaSeparatedIntegerField(CharField): 483 491 def get_manipulator_field_objs(self): … … 587 595 # doesn't support microseconds. 588 596 if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'): 589 597 value = value.replace(microsecond=0) 590 value = smart_unicode(value) 598 #Firebird supports native datetime 599 if settings.DATABASE_ENGINE != 'firebird': 600 value = smart_unicode(value) 591 601 return Field.get_db_prep_save(self, value) 592 602 593 603 def get_db_prep_lookup(self, lookup_type, value): … … 995 1005 # doesn't support microseconds. 996 1006 if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'): 997 1007 value = value.replace(microsecond=0) 998 if settings.DATABASE_ENGINE == 'oracle':999 # cx_Oracle expectsa datetime.datetime to persist into TIMESTAMP field.1008 if settings.DATABASE_ENGINE in ('oracle', 'firebird'): 1009 # cx_Oracle and kinterbasdb expect a datetime.datetime to persist into TIMESTAMP field. 1000 1010 if isinstance(value, datetime.time): 1001 1011 value = datetime.datetime(1900, 1, 1, value.hour, value.minute, 1002 1012 value.second, value.microsecond) -
django/db/backends/__init__.py
45 45 autoindexes_primary_keys = True 46 46 inline_fk_references = True 47 47 needs_datetime_string_cast = True 48 needs_default_null = False 48 49 needs_upper_for_iops = False 49 50 supports_constraints = True 50 51 supports_tablespaces = False 51 52 uses_case_insensitive_names = False 53 uses_custom_icontains = False 54 uses_custom_startswith = False 52 55 uses_custom_queryset = False 53 56 54 57 class BaseDatabaseOperations(object): … … 65 68 This SQL is executed when a table is created. 66 69 """ 67 70 return None 68 71 72 def cascade_delete_update_sql(self): 73 """ 74 Returns the SQL necessary to make a cascading deletes and updates 75 of foreign key references during a CREATE TABLE statement. 76 """ 77 return '' 78 69 79 def date_extract_sql(self, lookup_type, field_name): 70 80 """ 71 81 Given a lookup_type of 'year', 'month' or 'day', returns the SQL that -
django/core/management/sql.py
263 263 # Make the definition (e.g. 'foo VARCHAR(30)') for this field. 264 264 field_output = [style.SQL_FIELD(qn(f.column)), 265 265 style.SQL_COLTYPE(col_type)] 266 field_output.append(style.SQL_KEYWORD('%sNULL' % (not f.null and 'NOT ' or ''))) 266 nullstring = "" 267 if connection.features.needs_default_null: 268 nullstring = "DEFAULT " 269 field_output.append(style.SQL_KEYWORD('%sNULL' % (not f.null and 'NOT ' or nullstring))) 267 270 if f.unique and (not f.primary_key or connection.features.allows_unique_and_pk): 268 271 field_output.append(style.SQL_KEYWORD('UNIQUE')) 269 272 if f.primary_key: … … 276 279 if inline_references and f.rel.to in known_models: 277 280 field_output.append(style.SQL_KEYWORD('REFERENCES') + ' ' + \ 278 281 style.SQL_TABLE(qn(f.rel.to._meta.db_table)) + ' (' + \ 279 style.SQL_FIELD(qn(f.rel.to._meta.get_field(f.rel.field_name).column)) + ')' + 280 connection.ops. deferrable_sql()282 style.SQL_FIELD(qn(f.rel.to._meta.get_field(f.rel.field_name).column)) + ')' + \ 283 connection.ops.cascade_delete_update_sql() + connection.ops.deferrable_sql() 281 284 ) 282 285 else: 283 286 # We haven't yet created the table to which this field … … 335 338 final_output.append(style.SQL_KEYWORD('ALTER TABLE') + ' %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;' % \ 336 339 (qn(r_table), truncate_name(r_name, connection.ops.max_name_length()), 337 340 qn(r_col), qn(table), qn(col), 341 connection.ops.cascade_delete_update_sql(), 338 342 connection.ops.deferrable_sql())) 339 343 del pending_references[model] 340 344 return final_output … … 364 368 tablespace_sql)) 365 369 if inline_references: 366 370 deferred = [] 367 table_output.append(' %s %s %s %s (%s)%s ,' %371 table_output.append(' %s %s %s %s (%s)%s%s,' % 368 372 (style.SQL_FIELD(qn(f.m2m_column_name())), 369 373 style.SQL_COLTYPE(models.ForeignKey(model).db_type()), 370 374 style.SQL_KEYWORD('NOT NULL REFERENCES'), 371 375 style.SQL_TABLE(qn(opts.db_table)), 372 376 style.SQL_FIELD(qn(opts.pk.column)), 377 connection.ops.cascade_delete_update_sql(), 373 378 connection.ops.deferrable_sql())) 374 table_output.append(' %s %s %s %s (%s)%s ,' %379 table_output.append(' %s %s %s %s (%s)%s%s,' % 375 380 (style.SQL_FIELD(qn(f.m2m_reverse_name())), 376 381 style.SQL_COLTYPE(models.ForeignKey(f.rel.to).db_type()), 377 382 style.SQL_KEYWORD('NOT NULL REFERENCES'), 378 383 style.SQL_TABLE(qn(f.rel.to._meta.db_table)), 379 384 style.SQL_FIELD(qn(f.rel.to._meta.pk.column)), 385 connection.ops.cascade_delete_update_sql(), 380 386 connection.ops.deferrable_sql())) 381 387 else: 382 388 table_output.append(' %s %s %s,' % … … 412 418 (qn(r_table), 413 419 truncate_name(r_name, connection.ops.max_name_length()), 414 420 qn(r_col), qn(table), qn(col), 421 connection.ops.cascade_delete_update_sql(), 415 422 connection.ops.deferrable_sql())) 416 423 417 424 # Add any extra SQL needed to support auto-incrementing PKs -
django/contrib/contenttypes/models.py
1 1 from django.db import models 2 2 from django.utils.translation import ugettext_lazy as _ 3 3 from django.utils.encoding import smart_unicode 4 from django.conf import settings 4 5 5 6 CONTENT_TYPE_CACHE = {} 6 7 class ContentTypeManager(models.Manager): … … 31 32 global CONTENT_TYPE_CACHE 32 33 CONTENT_TYPE_CACHE = {} 33 34 34 class ContentType(models.Model): 35 class ContentType(models.Model): 35 36 name = models.CharField(max_length=100) 36 app_label = models.CharField(max_length=100) 37 model = models.CharField(_('python model class name'), max_length=100) 37 # Need this because of Firebird restrictions on index key size < 252 bytes 38 if settings.DATABASE_ENGINE == 'firebird': 39 app_label = models.ASCIICharField(max_length=96) 40 model = models.ASCIICharField(_('python model class name'), max_length=96) 41 else: 42 app_label = models.CharField(max_length=100) 43 model = models.CharField(_('python model class name'), max_length=100) 38 44 objects = ContentTypeManager() 39 45 class Meta: 40 46 verbose_name = _('content type') -
django/contrib/auth/models.py
6 6 from django.contrib.contenttypes.models import ContentType 7 7 from django.utils.encoding import smart_str 8 8 from django.utils.translation import ugettext_lazy as _ 9 from django.conf import settings 9 10 import datetime 10 11 import urllib 11 12 … … 72 73 """ 73 74 name = models.CharField(_('name'), max_length=50) 74 75 content_type = models.ForeignKey(ContentType) 75 codename = models.CharField(_('codename'), max_length=100) 76 # Need this because of Firebird restrictions on index key size < 252 bytes 77 if settings.DATABASE_ENGINE == 'firebird': 78 codename = models.ASCIICharField(_('codename'), max_length=100) 79 else: 80 codename = models.CharField(_('codename'), max_length=100) 76 81 77 82 class Meta: 78 83 verbose_name = _('permission')