Ticket #2763: django-mysql-zero-typcast-ticket2763.diff

File django-mysql-zero-typcast-ticket2763.diff, 1.6 KB (added by wam-djangobug@…, 17 years ago)

same content of last patch, but with different name and diff options to get interactive viewing to work

  • base.py

     
    1717
    1818DatabaseError = Database.DatabaseError
    1919
     20def typecast_mysql_time(s):
     21    # workaround mysql issue.
     22    # see http://code.djangoproject.com/ticket/433, 2763 and 2369
     23    if s == "00:00:00":
     24        # an empty or invalid field gets remapped to zeros
     25        return None
     26    return util.typecast_time(s)
     27   
     28
     29def typecast_mysql_timestamp(s):
     30    # workaround mysql issue.
     31    # see http://code.djangoproject.com/ticket/433, 2763 and 2369
     32    if s == "0000-00-00 00:00:00":
     33        # an empty or invalid field gets remapped to zeros
     34        return None
     35    return util.typecast_timestamp(s)
     36
     37def typecast_mysql_date(s):
     38    # workaround mysql issue.
     39    # see http://code.djangoproject.com/ticket/433, 2763 and 2369
     40    if s == "0000-00-00": 
     41        # an empty or invalid field gets remapped to zeros
     42        return None
     43    return util.typecast_date(s)
     44
    2045django_conversions = conversions.copy()
    2146django_conversions.update({
    2247    types.BooleanType: util.rev_typecast_boolean,
    23     FIELD_TYPE.DATETIME: util.typecast_timestamp,
    24     FIELD_TYPE.DATE: util.typecast_date,
    25     FIELD_TYPE.TIME: util.typecast_time,
     48    FIELD_TYPE.DATETIME: typecast_mysql_timestamp,
     49    FIELD_TYPE.DATE: typecast_mysql_date,
     50    FIELD_TYPE.TIME: typecast_mysql_time,
    2651})
    2752
     53
    2854# This should match the numerical portion of the version numbers (we can treat
    2955# versions like 5.0.24 and 5.0.24a as the same). Based on the list of version
    3056# at http://dev.mysql.com/doc/refman/4.1/en/news.html and
Back to Top