Ticket #8316: db-mysqltypeissue.6.diff
File db-mysqltypeissue.6.diff, 2.1 KB (added by , 16 years ago) |
---|
-
django/db/backends/__init__.py
71 71 interprets_empty_strings_as_nulls = False 72 72 can_use_chunked_reads = True 73 73 uses_savepoints = False 74 keys_need_similar_types = False 74 75 75 76 class BaseDatabaseOperations(object): 76 77 """ -
django/db/backends/mysql/base.py
68 68 class DatabaseFeatures(BaseDatabaseFeatures): 69 69 empty_fetchmany_value = () 70 70 update_can_self_select = False 71 keys_need_similar_types = True 71 72 72 73 class DatabaseOperations(BaseDatabaseOperations): 73 74 def date_extract_sql(self, lookup_type, field_name): -
django/db/models/fields/related.py
712 712 # of the field to which it points. An exception is if the ForeignKey 713 713 # points to an AutoField/PositiveIntegerField/PositiveSmallIntegerField, 714 714 # in which case the column type is simply that of an IntegerField. 715 # If the database needs similar types for key fields however, the only 716 # thing we can do is making AutoField an IntegerField. 715 717 rel_field = self.rel.get_related_field() 716 if isinstance(rel_field, (AutoField, PositiveIntegerField, PositiveSmallIntegerField)): 717 return IntegerField().db_type() 718 if isinstance(rel_field, AutoField) \ 719 or (not connection.features.keys_need_similar_types and 720 isinstance(rel_field, (AutoField, 721 PositiveIntegerField, 722 PositiveSmallIntegerField))): 723 return IntegerField().db_type() 718 724 return rel_field.db_type() 719 725 720 726 class OneToOneField(ForeignKey):