Ticket #8316: db-mysqltypeissue.6.diff

File db-mysqltypeissue.6.diff, 2.1 KB (added by Julian Bez, 16 years ago)

v6, fixed an oversight

  • django/db/backends/__init__.py

     
    7171    interprets_empty_strings_as_nulls = False
    7272    can_use_chunked_reads = True
    7373    uses_savepoints = False
     74    keys_need_similar_types = False
    7475
    7576class BaseDatabaseOperations(object):
    7677    """
  • django/db/backends/mysql/base.py

     
    6868class DatabaseFeatures(BaseDatabaseFeatures):
    6969    empty_fetchmany_value = ()
    7070    update_can_self_select = False
     71    keys_need_similar_types = True
    7172
    7273class DatabaseOperations(BaseDatabaseOperations):
    7374    def date_extract_sql(self, lookup_type, field_name):
  • django/db/models/fields/related.py

     
    712712        # of the field to which it points. An exception is if the ForeignKey
    713713        # points to an AutoField/PositiveIntegerField/PositiveSmallIntegerField,
    714714        # 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.
    715717        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()
    718724        return rel_field.db_type()
    719725
    720726class OneToOneField(ForeignKey):
Back to Top